Sunday, 12 January 2014

Creating an SSH key in PuTTY

Requirements



      PuTTY

      PuTTYgen

      Pageant


Generate the Key


Run PuTTYgen.exe.

SSH_keys_1

Click "Generate" and move your mouse.



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.'


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.



It should look similar to the following:
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBvo93MZvQS8gtB5+fy8yPT+6SrZfJAA4C4lJYydp/pf8KfXTU303xLiTSrXcwDOSUykBi7DVdloOIpZQtQOFJMEwXx+wMWausxp0T5W//pfMfZYTg4ZDDQwWG4bUAl+l6pFDwQwEtm2KN6C4lyfJNMDNqdtjqw9/HvAfO5xoyceQ==

You will want to protect the file and change its owner to the user in question. In this case, it will be 'thatguy.'
chmod 600 authorized_keys2
chown thatguy:psacln .ssh

Add the private key


Run Pageant.exe.



This application runs in the background. When it loads, it should be displayed in your tray.



Right click the icon and click on "Add Key."


Connect using your SSH key with PuTTY


Open PuTTY and connect as "thatguy@mt-example.com."



Since Pageant.exe has your passphrase stored, you connect without entering your password:

No comments:

Post a Comment