You use SSH to connect to a remote Linux server and you do this pretty often. You’re tired of having to type a password each time you SSH. You want to know if there’s a way to connect to a Linux server without having to type in a password. Here’s how:

Step 1

On your local machine, open a terminal with root access and type the following:

ssh-keygen -t rsa

This will generate a SSH key located in ~/.ssh/id_rsa.pub

Step 2

Now that you’ve generated a public SSH key, copy it so that you can paste the content onto your Linux server.

pbcopy < ~/.ssh/id_rsa.pub

Step 3

SSH into your Linux server (using your password for the last time) and open .ssh/authorized_keys

ssh username@
vi ~/.ssh/authorized_keys

Now paste your public SSH key into the file, then save and quit.


Alright, you should be set to go. Exit your SSH session and try to SSH into your Linux server again. If you did everything right, you should be able to log into your Linux server without being prompted for a password!