Saturday, 11 January 2014

Passwordless Connection to a Remote Server


Passwordless connection to a remote server can be done in TWO steps :


STEP #1 : Setup the Public key and send it to the server that is to be connected

i) cd ~/.ssh : ssh contains all the private and public keys
ii) ssh -keygen -t rsa [ do not enter password when asked ] : This will create two keys (a) private key (b)public key (.pub extension)
iii) scp ~/.ssh/id_rsa.pub [user]@[server]:~/ : This step will copy the public key to the target server

STEP #2 : Changing the permission of the copied key and storing it in authorized_keys folder

i) open a terminal on [target server] and mkdir ~/.ssh
ii) chmod 700 ~/.ssh
iii) touch ~/.ssh/authorized_keys
iv) cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
v) chmod 600 ~/.ssh/authorized_keys
vi) rm ~/id_rsa.pub
Now you can connect with the target server with command

ssh ip_adddess[xx.yy.zz.pp]

: This will take you to the target server without prompting for the password.

No comments:

Post a Comment