Passwordless SSH login
Many times requirement comes from development team that they need to login to remote server for some activity – be it ‘ftp’ or ‘copy’ or ‘writing’ on the remote server. In such cases, it is required that there is seamless and password less login from source server to target server.
I am going to discuss the way to achieve the same…
First of all be clear on
- what is the user on source server. say e.g. on application tier it is ‘applmgr’ and source server is A
- what is the user on target server – user could be same of different on target server. For my case, i would consider it to be different i.e. ‘wlshop’ and server is B
Step 1: Login to source server A using ‘applmgr’ user
Step 2: Generate public/private key pair using ssh-keygen command. This will prompt you to save the key in the default directory (/home/applmgr/.ssh/id_rsa). It will ask yo put the passsphrase. You may or may not enter the same
Step 3: Now the identification key is saved in /home/applmgr/.ssh/id_rsa and public key is saved in /home/applmgr/.ssh/id_rsa.pub
Step 4: Login to target server B using ‘wlshop’ user and create .ssh directory if not already present
Step 5: applmgr.A> cat .ssh/id_rsa.pub | ssh wlshop@B ‘cat >> .ssh/authorized_keys’. It will ask for wlshop@B password.
Step 6: Now you can login to B as ‘wlshop’ from server A without being prompted for password
applmgr.A> ssh wlshop@B
-Anand