Steve Levine

How to SSH Without Using a Password

  1. The basis of using ssh without typing your password is public key based authentication. You need to generate a pair of public/private keys for this.

  2. Firstly, generate your public/private keys using ssh-keygen

1
% ssh-keygen -t rsa

You must use the -t option to specify that you are producing keys for SSH using RSA. This will generate your id_rsa and id_rsa.pub in the .ssh directory in your home directory.

  1. Copy ~/.ssh/id_rsa.pub to the server.
1
% scp ~/.ssh/id_rsa.pub user@host:.
  1. On the server run the following commands:
1
2
% cat id_rsa.pub >> ~/.ssh/authorized_keys
% chmod 644 ~/.ssh/authorized_keys

Thats it! Easy as 1,2,3.

Now you should be able connect to the server via ssh without being challenged for a password.

If for some reason, it is not working for you, you may also need to do one of the following things to get it working:

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

Related Posts

Fork me on GitHub