Join us

How to SSH Into a Linux(Ubuntu) Server With a New User Using the Terminal

This is a simple beginner's tutorial where I will demonstrate how to ssh into an Ubuntu server with a new local user.

Why this tutorial; it is to show how different users can ssh into an Ubuntu/Linux server hosted on the Cloud (AWS, GCP, Azure), etc.

Prerequisites

  1. Cloud account (AWS, Azure, GCP, DigitalOcean, or any other cloud provider)
  2. Basic Linux knowledge.

Steps to follow

  1. I will be using AWS to create and launch a new EC2 instance. I choose an Ubuntu Server 20.04 LTS (HVM), SSD Volume Type Amazon Machine Image (AMI), and t2micro instance type which is a free tier instance.
  2. SSH into the newly created server through your terminal.

Ubuntu server created

3. Create a new user (chinel) and the goal is to ssh as chinel user instead of Ubuntu user.

Creating new user

Note: While creating the new user, remember to use sudo adduser command.

4. Change from the ubuntu user to the new user I created which is chinel using the su command.

5. Use the Linux command ls -al to check for .ssh folder which will show you all the files in the directory including hidden files. We will see that there is no .ssh folder in our new user’s list of directories. To fix this, we need to add the public key that exists in the Ubuntu user’s ~/.ssh/authorized_keys file to Chinel user.

6. Logout of the chinel user using exit command. This will take you back to the ubuntu user.

7. Enter into /home/ubuntu/.ssh/authorized_keys and copy the content.

8. Change back to the chinel user and create a new .ssh directory.

9. Using vim editor, create a file called authorized_keys inside the .ssh folder and paste the contents from /home/ubuntu/.ssh/authorized_keys copied earlier.

10. Exit and log out of the Ubuntu server.

11. Now I have my .ssh folder and my keys in the authorized_key file and can now ssh into my chinel user directly.

Conclusion

This is is a simple tutorial on how to ssh into an Ubuntu server/instance with a non-default user.

PS: This is my first article on Medium, please like and share. Thank you.


Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN account now!

User Popularity
19

Influence

2k

Total Hits

1

Posts

Mentioned tools