From f4655165109b7034844c1f93d8dc599996728ba2 Mon Sep 17 00:00:00 2001 From: elAgala Date: Sun, 4 Aug 2024 20:06:50 +0000 Subject: [PATCH] Create user docs | setup.sh creation --- create-user.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.sh | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 create-user.md create mode 100644 setup.sh diff --git a/create-user.md b/create-user.md new file mode 100644 index 0000000..ad0a122 --- /dev/null +++ b/create-user.md @@ -0,0 +1,52 @@ +# Creating a new user on your Linux server and configuring it for administrative tasks + +## 1. Create a New User + +- Log in to Your Server as the root user or a user with sudo privileges. +- Add a New User: + `sudo adduser newusername` + Replace `newusername` with the desired username. +- Follow the prompts to set the user's password and provide additional information. + +## 2. Grant Sudo Privileges (Optional) + +If you need the new user to have administrative privileges, add the user to the sudo group: + +- Add User to the Sudo Group: + `sudo usermod -aG sudo newusername` + This command adds the user to the sudo group, which grants administrative permissions. + +## 3. Configure SSH Access + +- Switch to the New User: + `su - newusername` +- Create SSH Directory and Authorized Keys: + `mkdir -p ~/.ssh + chmod 700 ~/.ssh + touch ~/.ssh/authorized_keys + chmod 600 ~/.ssh/authorized_keys` +- Add Your Public Key to authorized_keys: + - Open authorized_keys in an editor: + `vim ~/.ssh/authorized_keys` + - Paste your SSH public key into the file + +## 4. Configure SSH Access for New User + +Ensure the new user can log in via SSH: + +- Edit the SSH Configuration File (/etc/ssh/sshd_config): + `sudo nano /etc/ssh/sshd_config` +- Verify or Add the Following Settings: + `PermitRootLogin no + AllowUsers newusername` + `PermitRootLogin no` disables root login via SSH. + `AllowUsers newusername` allows the new user to log in. +- Restart SSH Service: + `sudo systemctl restart ssh` + +## 5. Test SSH Access + +- Log Out from the Root User or current session. +- Log In as the New User: + `ssh newusername@your_server_ip` +- Verify that you can access the server with the new user. diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..81b8c02 --- /dev/null +++ b/setup.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Update and install necessary packages +sudo apt update +sudo apt install -y curl gnupg lsb-release + +# Install Node.js +curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - +sudo apt install -y nodejs + +# Install PM2 +sudo npm install -g pm2 + +# Install Nginx +sudo apt install -y nginx + +# Create files and directories +sudo mkdir -p /var/www/myapp +sudo touch /var/www/myapp/index.html +sudo ln -s /var/www/myapp /var/www/html/myapp + +# Set up default Nginx config +cat <