Passwordless login between linux host
Scenario:
You have two servers, Server-A and Server-B – 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 Server-A 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:
cat /root/.ssh/id_dsa.pub
Step2: Copy Server-A’s public key to ServerB SSH in to Server-B and paste the contents from /root/.ssh/id_dsa.pub from Server-A (above) in to /root/.ssh/authorized_keys on Server-B:
If the /root/.ssh directory does not exist, create it first:
$mkdir /root/.ssh
$vim /root/.ssh/authorized_keys
Set the required permissions on the authorized_keys file:
$chmod 0600 /root/.ssh/authorized_keys
Now try and SSH to Server-A from Server-B – you should not be prompted for a password.
The same process can be used for other users, apart from root. If you want Server-B to have passwordless SSH access to Server-A, perform the same steps as above, but swap Server-A for Server-B the next time you do it.
No comments:
Post a Comment