April 20, 2023

How To Setup Multiple SSH Users On Ubuntu 20.04

Abhishek Thakur

If you have a Ubuntu Server 20 running, it’s likely that you’ll need to set up multiple SSH users at some point. This can be useful for allowing multiple users to access the server with their own SSH keys and credentials. In this blog post, we’ll guide you through the steps on how to setup multiple SSH users on your Ubuntu Server 20.

Step 1: Create new user accounts

The first step is to create new user accounts on your Ubuntu Server. To create a new user account, open a terminal window and run the following command:

sudo adduser <username>

Replace <username> with the name you want to give to the new user. This command will create a new user account and prompt you to set a password and other details.

Step 2: Grant SSH access

Once you have created new user accounts, you need to grant them SSH access. To do this, you will need to add their SSH public keys to the authorized_keys file. You can use the following command to create a new authorized_keys file for each user:

sudo mkdir /home/<username>/.ssh
sudo touch /home/<username>/.ssh/authorized_keys

Next, open the authorized_keys file for the user you just created:

sudo nano /home/<username>/.ssh/authorized_keys

Paste the user’s SSH public key into this file, then save and close it.

Step 3: Configure SSH access

Now that you have created new user accounts and granted them SSH access, you need to configure the SSH access to ensure that only authorized users can access your server. Open the SSH configuration file in a text editor:

sudo nano /etc/ssh/sshd_config

Find the line that reads “PermitRootLogin yes” and change it to “PermitRootLogin no”. This will disable root login over SSH. You should also find the line that reads “PasswordAuthentication yes” and change it to “PasswordAuthentication no”. This will disable password authentication and require SSH keys instead.

Save and close the file, then restart the SSH service:

sudo systemctl restart sshd

Step 4: Test SSH Access

Finally, you should test SSH access for each user to ensure that everything is working correctly. Open a new terminal window and run the following command:

ssh <username>@<server-ip>

Replace <username> with the name of the user you want to test and <server-ip> with the IP address of your Ubuntu 20.04. If everything is working correctly, you should be able to log in to your server using the new user account.

Congratulations! You have now successfully learned the steps on how to setup multiple SSH users on your Ubuntu 20.04 server . You can repeat the above steps to create and grant SSH access to additional users as needed.


Buy Ubuntu Root Server

Popular Blog Posts