Ubuntu User Setup Guide
This guide covers the essential steps for setting up a new user on a fresh Ubuntu server.
0. Install SSH Server (If missing)
If your Ubuntu system doesn't have SSH installed, you can install the OpenSSH server with the following commands:
sudo apt update
sudo apt install openssh-server -yAfter installation, ensure the service is running:
Method 1: Using systemctl (Standard)
sudo systemctl status ssh
sudo systemctl enable --now sshMethod 2: Using service (Docker / WSL / Non-systemd) If you see "System has not been booted with systemd", use this:
sudo service ssh status
sudo service ssh start1. Create a New User
Use the adduser command to create a new user. This command will prompt you for a password and user information.
sudo adduser <username>2. Grant Sudo Privileges
To allow the new user to execute commands with root privileges, add them to the sudo group.
sudo usermod -aG sudo <username>3. Configure SSH Access
Log in as the New User
Switch to the newly created user.
su - <username>SSH Method 1: Password Authentication (Common)
By default, Ubuntu allows password-based login for new users. If you prefer this method, you can skip adding SSH keys.
Note: Ensure you have set a strong password during the adduser step.
SSH Method 2: Key-based Authentication (Optional)
If you also want to use SSH keys for better convenience/security:
Create SSH Directory
mkdir -p ~/.ssh
chmod 700 ~/.sshAdd Your Public Key
Create or edit the authorized_keys file and paste your local public key into it.
nano ~/.ssh/authorized_keysSet Correct Permissions
chmod 600 ~/.ssh/authorized_keys4. Set Default Shell (Optional)
If you prefer using Zsh (and have it installed), you can change the default shell for the user.
sudo chsh -s /bin/zsh <username>5. Basic Security Settings
Ensure Password Authentication is Enabled
If you cannot log in with a password, ensure the following is set in /etc/ssh/sshd_config:
Edit the config:
bashsudo nano /etc/ssh/sshd_configVerify:
confPasswordAuthentication yesRestart SSH:
Standard:
bashsudo systemctl restart sshDocker / WSL:
bashsudo service ssh restart
Disable Root Login
It's a best practice to disable direct root login via SSH to force using your new user.
In /etc/ssh/sshd_config:
PermitRootLogin noThen restart the SSH service:
Standard:
sudo systemctl restart sshDocker / WSL:
sudo service ssh restart