Monday, July 25, 2011

Automatically login a ssh session using putty

Putty is used to connect to remote server and for day to day tasks developer login into remote machine using putty. User have to input username/password for every login. This process can be automated to save some time.


1. Downlaod PuTTY
2. Download PuTTYgen
3. Run PuTTYgen
4. Select SSH-2 DSA as the "Type of Key" to generate
5. Click on generate button and move your mouse around so that randomness is generated
6. Click on “Save Private Key” and save it to your computer
7. Copy the entire content inside the box to your clipboard (this is your generated public key).
8. Login to your SSH server using putty (by using user name and password)
9. Create file ~/.ssh/authorized_keys and put your public key on a single line (from step 7)
10. Make this file readable (chmod +r )
11. Open PuTTY, navigate to Connection->Data and fill in the auto-login username
12. Navigate to Connection->SSH->Auth and under Private-key, browse to the file you had saved earlier on your computer. (from step 6)

You are done. Now whenever you login into your remote machine, it will login automatically.

No comments: