(dv):Create SSH key in PuTTY

  • This page was last modified on December 13, 2010, at 21:03.
The (mt) Community Wiki is a collaborative project. Any (mt) Media Temple customer or employee may contribute. Not all articles and/or content have been tested for accuracy by (mt) Media Temple.

For officially moderated and tested articles, be sure to visit our KnowledgeBase.

From (mt) Community Wiki

Contents

This article will guide you through using SSH keys with PuTTY.

Overview

Generally, you connect via SSH by telling the server your password. You can add another layer of security by using an SSH key. This is a key pair: A public key and a private key.

Download PuTTY

You will need PuTTY, PuTTYgen, and Pageant. You can either download them individually here or you can download the .zip file containing all the binaries (except PuTTYtel) and also the help files here.

Generate the key

Run PuTTYgen.exe.
SSH keys-1.jpg

Click Generate and move your mouse.
SSH keys-3.jpg

Once the key is generated, enter your Key passphrase. Be sure to use a strong password; read our guide here.

Then click Save public key and Save private key.
SSH keys-4.jpg

Select & configure your user

Let's choose a user for which to create the SSH key. In our example, the user is thatguy for mt-example.com. This is an already existing FTP user with SSH access.

Connect to your (dv) Dedicated-Virtual Server as the root user.


su thatguy
cd /var/www/vhosts/mt-example.com
mkdir .ssh
chmod 700 .ssh
cd .ssh
vi authorized_keys2

Cut and paste on one line your public ssh key.
SSH keys-5.jpg

It should look something like:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBvo93MZvQS8gtB5+fy8yPT+6SrZfJAA4C4lJYydp/pf8KfXTU303xLiTSrXcwDOSUykBi7DVdloOIpZQtQOFJMEwXx+wMWausxp0T5W//pfMfZYTg4ZDDQwWG4bUAl+l6pFDwQwEtm2KN6C4lyfJNMDNqdtjqw9/HvAfO5xoyceQ==

Now, let's protect that file and change owner to thatguy.

chmod 600 authorized_keys2
chown thatguy:psacln .ssh

Add the private key

Run Pageant.exe.
SSH keys-6.jpg

This application runs in the background. When it loads, it should be displayed in your tray.
SSH keys-7.jpg

Right click the icon and click on Add Key.
SSH keys-8.jpg

Connect using your SSH key with PuTTY

Open PuTTY and connect as thatguy@mt-example.com.
SSH keys-9.jpg
Since Pageant.exe has your passphrase stored, you connect without entering your password:
SSH keys-10.jpg