Passwordless SSH (Public Key Authentication) for CentOS 5, CentOS 6, Ubuntu, Debian, Linux in GeneralPosted: November 8, 2011 at 6:06 pm | Tags: CentOS 5 passwordless SSH, CentOS 6 passwordless SSH, Debian passwordless SSH, Linux passwordless SSH, Passwordless SSH, quick passwordless SSH, simple passwordless SSH, Ubuntu passwordless SSH
You have two servers, ServerA and ServerB – you would like ServerA to be able to SSH in to ServerB without a password. Use this simple tutorial to achieve this:
Step 1: Generate public key on ServerA
SSH in to ServerA and enter the following command. Keep pressing enter (accept the defaults) – do not enter a passphrase.
ssh-keygen -t dsa
This should have generated a file, /root/.ssh/id_dsa.pub
Copy the contents of the file above:
Step2: Copy ServerA’s public key to ServerB
SSH in to ServerB and paste the contents from /root/.ssh/id_dsa.pub from ServerA (above) in to /root/.ssh/authorized_keys on ServerB:
If the /root/.ssh directory does not exist, create it first:
Set the required permissions on the authorized_keys file:
chmod 0600 /root/.ssh/authorized_keys
Now try and SSH to ServerA from ServerB – you should not be prompted for a password. The same process can be used for other users, apart from root. If you want ServerB to have passwordless SSH access to ServerA, perform the same steps as above, but swap ServerA for ServerB the next time you do it.