Skip to content
My GitHub Profile My Twitter Profile

[Linux] Login SSH without password

Here you can see how configurate your computer and server to login to your SSH server without password.

1.- Generate SSH key

First of all, you need to generate your SSH key. You can do it with the following command:

mkdir ~/.ssh
cd ~/.ssh
ssh-keygen

The program prompts you to enter a file name for the key pair. Remember that you must not enter a passphrase. In this example, the file name is id_rsa.

2.- Register the private key in the SSH agent

ssh-add ~/.ssh/id_rsa

3.- Copy the public key to the server

ssh-copy-id -i ~/.ssh/id_rsa.pub [USERNAME]@[HOST]

4.- Create ssh config file (optional)

touch ~/.ssh/config

Edit the file and add the following lines:

Host [NAME]
    HostName [HOST]
    User [USERNAME]
    Port [PORT]
    IdentityFile ~/.ssh/id_rsa

5.- Login to the server

ssh [NAME]

If the server is configured correctly, you will be able to login without password.