Use puTTY to automatically login a SSH session

Many thanks to Jon Lee at jonlee.ca for this excellent procedure allowing for the automtic login of a session using SSH and puTTY.exe terminal emulator. You da man!

——————————-

From his site:

As many web developers can attest to, logging into your server through SSH (Secure Shell) is one of the more common day-to-day tasks (you can even use it as a secure tunnel for your traffic). It only makes sense to automate this process which in turn can save many many keystrokes.

This how-to is written with PuTTY and Windows in mind and requires several other tools that are available from PuTTY’s website. So from their download page, make sure you have these files:

  • PuTTY (putty.exe)
  • PuTTYgen (puttygen.exe)

Then to automate SSH login, do the following:

  1. Run PuTTYgen.
  2. Select SSH-2 DSA as the Type of Key to generate.
  3. Click generate and move your mouse around to generate randomness.
  4. Click “Save Private Key” and save it somewhere on your computer.
  5. Copy the entire content inside the box to your clipboard (this is your generated public key).
  6. Login to your SSH server.
  7. Create the file ~/.ssh/authorized_keys containing the generated public key (from step 3) on a single line.
  8. Make this file readable (chmod 755).
  9. Then open up PuTTY and navigate to Connection->Data and fill in the auto-login username.
  10. Navigate to Connection->SSH->Auth and under Private-key, browse to the file you had saved earlier on your computer.

That’s it! Now you can try logging in to your SSH server and it should login automatically. If it works, make sure you save your session so you don’t have to repeat these steps every time!

Hopefully these steps work for everyone! Let me know if there are any problems.

——————————-

Had some problems with a CentOS5 server not accepting keys… found that this server was being finicky for some reason, and used this article on how to generate the keys on the Linux server, and then import the public key to the client Windows box. To make it automatically login simply do not enter any passphrase. This is probably a huge security risk or something like that, but if you’re using it on a secured LAN then perhaps it’s ok.

Posted under Linux, Network

This post was written by Content Curator on November 27, 2009

Tags: , , , , , , , , , , , , , , , , , ,

Trackbacks

More Articles: