In this post I would explain how to make the 2 servers( Remote and Local) password less .
Lets take a scenario
Resources : ServerA , ServerBRequirements : To make ServerB password less (i.e., while you enter
‘sshusername@ServerB’
it should not prompt you for a password )Explanation :To do this Generate a key pair on ServerA ( There are 2 types of keys rsa and dsa , you can use anyone of those)
ServerA@db2:~/.ssh> ssh-keygen -t rsa
Here is what you get
Generating public/private rsa key pair. Enter file in which to save the key (/home-dir/.ssh/id_rsa): Enter passphrase (empty for no passphrase):Your Password here Enter same passphrase again:Your Password here Your identification has been saved in /home-dir/.ssh/id_rsa. Your public key has been saved in /home-dir/.ssh/id_rsa.pub. The key fingerprint is: 52:d9:b3:84:9d:b0:29:6c:5c:76:9c:70:81:84:c9:74
So there we got 2 keys generated one public key (.pub) and other private . This public key is what we need to copy to ServerB to make a link between these 2 servers
Now the question is where to copy in ServerB
Well it should always be copied to .ssh directory of the Target Server of the username
Here is how you do that
scp id_rsa.pub user@ServerB:/home-dir/.ssh/authorized_keys The authenticity of host ‘ServerB (ServerB)’ can’t be established. RSA key fingerprint is 7b:02:49:c9:17:3d:02:72:74:44:40:5a:00:64:b3:c6. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘ServerB’ (RSA) to the list of known hosts. user@ServerB’s password:
this worked perfectly and it helped me save a lot time from typing passwords all time
ReplyDeleteAdding to your document a more detailed explanation:
ReplyDeletehttp://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/
I follow that site , its very informative
ReplyDelete