Monday, December 24, 2012

How to SSH from one server to another without password ?

How to SSH from one server to another without password ?


On source server side: 


First generate public key using rsa

#ssh-keygen -t rsa      

( here it will ask some questions, please give all default options, especially we have to press enter (leave as empty) in the passphrase option)

Copying the .pub files content from source server to target server.
scp ~/.ssh/id_rsa.pub username@destination:~/.ssh/authorized_keys 

                                                         (OR)

Better we can follow the below steps
cp ~/.ssh/id_rsa.pub ~/.ssh/authorize_keys

next copy this authorize_keys file to client /root/.ssh/
scp ~/.ssh/authorize_keys username@destination:~/.ssh/.

Now client doesn't ask any password.