Putty is an ssh client for Microsoft Windows which can automate secure logins to remote computers. This tutorial allows you to automate these logins using your personal public/private key pair.
Putty can be downloaded from here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/. Download and install the entire putty distribution.
During this procedure the following high-level steps are taken:
- First, create a public-private key pair using
puttygen
. - Second, create a session for logging into a particular host. This session will include the IP address and can include the username and location of your private key
- Lastly, add your public key to the host you’ll be logging into.
Each of these steps is detailed below.
Create a private key
Follow the Putty documents for using the using puttygen
application. Create a private key with a passphrase. Choose a passphrase that is easy for you to remember, but is long, like a complete sentence, with misspellings or numbers included.
As an example only, “A p3nny sav3d is a p3nny 3arn3d”.
Save the private key in a directory only accessible to you.
Create a Putty session for each host you access
- Launch the Putty configuration utility.
- In the Connection -> Data, enter the name of the user to login with
- In the Connection -> SSH -> Auth, enter the path to the private key file. This path is where the private key is stored on your PC.
- In the Session category, enter the IP Address of the host
- Finally, in the Session category, save the session using a helpful name
Place your public key on the host you’ll be logging into
On a UNIX/Linux host, using $HOME as the path to the home directory of the user you login as. You’re going to make a directory called “.ssh” to store ssh-specific files. Then you’ll add a file for authorized keys.
mkdir .ssh
cd .ssh
vi authorized_keys
Launch the
puttygen
application on your PC and follow the directions to load your private key.- Select and copy the public key text from the
puttygen
window.
In the active window on the host, paste into the vi editor using SHIFT-INSERT. - Save and quit the editor.
- Then make the directory and file executable.
chmod go-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keys
- To login using the session you’ve created, launch the putty application.
- Select from the Saved Settings list the session you created in step 5, above.
- Click Load.
- Click Open
- You should be prompted to enter your passphrase. Enter the passphrase.
The login should be successful. Resolve any errors before continuing.
Automating passphrase Entry
The steps above require you to enter your passphrase every time you log in to this host. That’s way too much work! Entering the passphrase can be automated using the Pagent application included in the putty distribution.
- Launch the
Pagent
application. - Click Add Key.
- Select the path to the private key you created above. Click Open.
- Pagent will prompt you to enter the passphrase you entered when the private key was created.
- Now when you select a Putty session, you will be logged in automatically.
You should be logged into the host without being asked to enter your password or your passphrase. Resolve any errors before continuing.
Automated Login
Lastly, a shortcut can be created which logs you in with a single double-click.
- Find the Putty application on your PC. Right-click and select Create Shortcut.
- Right-click on the shortcut and select Properties.
- Click on the Shortcut tab of the Properties dialog box.
- In the Target box append load <session> where <session> is the Putty session name created above.
- Rename the shortcut with a meaningful name.
- Double-click the shortcut to login to this host.
@Kim Smith.
Glad you liked the article. I hope by automating your logins it saves you significant time. I login to about a dozen systems each day, and the time saved not typing and not looking up passwords really adds up.
Thanks for reading!