Hey folks,
So I’ve seen a lot of people open putty and then select their host and finally enter a user name and password. I don’t do that. I don’t want to either. Why would I? I’m a computer scientist/programmer/whatever. I should not do repetitive tasks. I should automate it. Password free SSH login is just that: Automation.

How do you do it?

This isn’t rocket science. Let us start with what SSH is Secure Shell. OMG! That didn’t help. It is a protocol that helps you to connect to remote machines securely over unsecured networks. Over use of secure you might say. You generally need an SSH server and an SSH client for this purpose. Generally most of your enterprise linux hosts would be configured to allow your personal workstation to connect to it using an SSH client like Putty. There are several different versions of this protocol too. But I’m not a networking protocol geek. So enough said. Let us go right into what you have to do to setup your computer to log in.

  1. Download putty and puttygen.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/
  2. Open puttygen.exe after installation. You’ll see some options to choose the type of key to generate. Choose the one that suits you. I chose the default and my SSH server supports that too. SSH-2(RSA)
  3. I left the number of bits in the key as the default 1024
  4. Then click Generate, and as the the key is being generated, you may move your mouse over the panel and create more randomness. I didn’t include screenshot out of fear of the application’s UI changing over time. 
  5. Once the public key is generated, you’ll be prompted with a panel to enter Key passphrase. DO NOT ENTER PASSPHRASE. The whole purpose of this was to do password free entry, so do not type in a passphrase.
  6. Save the key to a safe location. Now please don’t print it and keep it in a safe. Just store it somewhere in your personal folder. C:\.ssh\puttykey\worklaptop.ppk
  7. Open the file in a text editor, choose your favourite and copy the lines that follows Public Lines
  8. Now for one last time, open putty and connec to the remote host using your userid and password.
  9. In your home directory there should be a default .ssh directory (hidden one), else just create one of that name. This is important as this is the default location that your sshAgent would look for your public keys.
  10. Inside that directory create a file called authorized_keys if it doesn’t exist alreadyd, if it did, then just edit it. 
  11. Type " ssh-rsa " (including spaces in the quotes, exclude the quotes) on the line that you intend to paste your public key, which you copied from the workflaptop.ppk file. Paste your public key. save the file and close it.
  12. Generally it is good practice to keep this file private for you. So run the chmod 600 authorized_keys  and that should make your authorized_keys file readable and editable only by you
  13. This completes your configuration of the SSH server to allow you to do a password free login!
  14. Exit this existing connection to the remote host and try logging in again using Putty to the same remote host. It shouldn’t prompt you for a password.
  15. In your Putty, load the session you generally use for connecting to your remote host. 
  16. On the left hand panel expand the Connection menu. 
  17. Choose the Data option and fill in the auto-login username field with the username you would like to automatically log in with. If your windows username is also your Linux username, then just choose the use system username option.
  18. Again back to the left hand panel, expand the SSH menu and choose the Auth option
  19. Fill in the private key file location in your case, if you followed my instructions earlier it would be C:\.ssh\puttykey\worklaptop.ppk
  20. Select the Sessions option from the left pane menu, and now save session. This should make sure that your regular session now has the SSH settings saved with it. 
  21. That is all your honor. Happy SSH-ing without a password to your remote host.