
Sharing one root password between several people is the fastest way to lose track of who changed what on a server. Giving each person their own SSH account is simple and much safer: everyone has their own key, their own home folder and their own permissions, and you can remove one person without changing anyone else's access. This guide shows how to create several SSH users on Ubuntu (22.04, 24.04 or 26.04, and the same steps on 20.04), set up key-based logins, control who may connect, give some users admin rights and others only file access, and see who's logged in.
Quick answer
sudo adduser alice
sudo adduser bob
sudo usermod -aG sudo alice # alice gets admin rights
sudo mkdir -p /home/bob/.ssh && sudo nano /home/bob/.ssh/authorized_keys # paste bob's public key
sudo chown -R bob:bob /home/bob/.ssh && sudo chmod 700 /home/bob/.ssh && sudo chmod 600 /home/bob/.ssh/authorized_keys
Step 1: Create the user accounts
Create one account per person, never shared accounts:
sudo adduser alice
sudo adduser bob
sudo adduser carol
adduser creates the home directory, sets the shell to Bash and asks for a password. Even if you'll use SSH keys, set a strong password; it's needed for sudo.
Step 2: Decide who gets admin rights
Only users who really manage the server should be in the sudo group:
sudo usermod -aG sudo alice
groups alice
Everyone else stays a normal user who can work in their home directory and in folders you grant them, for example a shared project folder:
sudo groupadd devs
sudo usermod -aG devs bob
sudo usermod -aG devs carol
sudo mkdir -p /srv/project
sudo chown root:devs /srv/project
sudo chmod 2775 /srv/project # group members can write; new files keep the group
Step 3: Give each user their own SSH key
Each person generates a key pair on their own computer and sends you only the public key:
# on the user's computer (Linux, macOS or Windows PowerShell)
ssh-keygen -t ed25519 -C "bob@laptop"
# the public key is in ~/.ssh/id_ed25519.pub
On the server, add it to that user's authorized_keys file with the right ownership and permissions:
sudo mkdir -p /home/bob/.ssh
echo "ssh-ed25519 AAAA...bob@laptop" | sudo tee -a /home/bob/.ssh/authorized_keys
sudo chown -R bob:bob /home/bob/.ssh
sudo chmod 700 /home/bob/.ssh
sudo chmod 600 /home/bob/.ssh/authorized_keys
Wrong permissions are the most common reason key logins fail; SSH ignores keys in files others can write to.
Step 4: Control who can log in over SSH
Create /etc/ssh/sshd_config.d/users.conf to allow only your SSH group, disable root login and, once everyone's key works, disable passwords:
sudo groupadd sshusers
sudo usermod -aG sshusers alice
sudo usermod -aG sshusers bob
sudo usermod -aG sshusers carol
# /etc/ssh/sshd_config.d/users.conf
AllowGroups sshusers
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
Check the configuration and reload, and keep your current session open while you test a new login from another terminal:
sudo sshd -t && sudo systemctl reload ssh
Adding a new person later is then just: create the user, add their key, add them to sshusers.
Step 5: Give some users file access only (SFTP)
For people who only upload files, such as a designer updating a website, give them SFTP without a shell, locked into one folder:
sudo groupadd sftponly
sudo adduser --shell /usr/sbin/nologin dave
sudo usermod -aG sftponly,sshusers dave
sudo chown root:root /home/dave && sudo chmod 755 /home/dave
sudo mkdir /home/dave/uploads && sudo chown dave:dave /home/dave/uploads
# add to /etc/ssh/sshd_config.d/users.conf
Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
Dave can connect with FileZilla or WinSCP over SFTP, sees only his home folder, and can write only to uploads.
Step 6: See who is logged in and what they did
who # who is logged in now
last -n 20 # recent logins
sudo journalctl -u ssh --since today | grep Accepted
sudo grep sudo /var/log/auth.log | tail # recent sudo commands
Remove a user's access
sudo gpasswd -d bob sshusers # block SSH, keep the account
sudo deluser --remove-home bob # delete the account and files
Because nobody shared a password, removing one person doesn't affect anyone else.
Frequently asked questions
How do I add another SSH user on Ubuntu?
Create the account with sudo adduser name, add their public key to /home/name/.ssh/authorized_keys with permissions 700/600, and include them in your allowed SSH group.
Can several users log in over SSH at the same time?
Yes. SSH supports many simultaneous sessions, each with its own user and permissions.
How do I restrict SSH to certain users?
Use AllowUsers or AllowGroups in the SSH server configuration and reload SSH.
How do I give a user SFTP access but no shell?
Set their shell to /usr/sbin/nologin and use a Match Group block with ForceCommand internal-sftp and ChrootDirectory.


