How to setup password-less SSH authentication
January 18th, 2007
The following allows you to configure SSH out of the box to do password less authentication, this can be helpful if you wish to automate processes such as backups between hosts over insecure networks.
For ease of explanation we will call the servers source (the server you’re connecting from) and destination (the server you wish to connect to).
- On the source server execute the following (as the user you will be connecting from). This will generate RSA keys using ssh-keygen. When it asks you to “Enter passphrase” push enter if you wish to not use a password
|
ssh-keygen –t rsa |
- In the users home directory there should be an .ssh directory, inside here are two new files id_rsa.pub and id_rsa. Do not give out the id_rsa file this is the private key set
- Copy the id_rsa.pub file to the destination server(s) into the user’s .ssh directory and name it authorized_hosts. Ensure the mode of the file is 0600 and the user and group are the respective owners
Notes
- If the .ssh folders have permissions other than 0700 and ownership other than the respective user and group you may end up with authentication errors
- If you copy and paste the authorized_hosts file ensure the information is in one line otherwise you may end up with authentication errors
- If you are attempting to execute this as the user root and are have authentication problems ensure that root is allowed to connect (this is in the /etc/ssh/sshd_config file on the destination server)
- If you are having authentication issues ensure the user has a valid shell on the destination server
