SSH Remote Login Without Password in Linux

ssh

By default, if you want to do remote console with SSH, server (A) will prompt you the password of user (a) in the server. Sometime you need to call ssh not in interactive mode, for example in shell script, then you may need to make the script secure without storing any password there. Basically Linux provide such way to remote server without typing any password, please take look following steps.

First generate a pair of authentication keys. Do not enter a passphrase:

Now use ssh to create a directory ~/.ssh as user a on A. (The directory may already exist, which is fine):

Finally append new public key to a@A:/ssh/authorized_keys and enter a’s password one last time:

From now on you can log into A as a from client as user without password:

 

A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:

  • Put the public key in .ssh/authorized_keys2
  • Change the permissions of .ssh to 700
  • Change the permissions of .ssh/authorized_keys2 to 640

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*