Linux SSH without password


Whenever we login into remote server with ssh, it requires password authentication.

Let’s try to ssh check that you can ssh to the local host.

$ ssh localhost

By default it should ask for password.

To login without password we need to generate ssh keys, to generate use following command:

$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa

Above command will create 2 files id_dsa, and in .ssh directory which is located in home directory.

Now copy to authorized_keys.

$ cat ~/.ssh/ >> ~/.ssh/authorized_keys

Then try to ssh to your local host, it shouldn’t ask for password.

Similarly to login into a remote server copy content into remote server ~/.ssh/authorized_key file. Use following command to copy.

$ cat | ssh user@serverName/IP 'cat >> .ssh/authorized_keys'

Some recent version’s of ssh requires following permissions and authorized_keys2:

  • Put the public key in .ssh/authorized_keys2 
    • $ cp .ssh/authorized_keys .ssh/authorized_keys2
  • Change permission of .ssh directory to 700
    • $ chmod 700 .ssh
  • Change permission of .ssh/authorized_keys2 to 640
    • $ chmod 640 .ssh/authorized_keys2



One comment on “Linux SSH without password

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s