SSH with private/public key authentication

Some of you, like me, might use Putty.exe as your SSH client in Windows operating system. Thankfully it has a tool called PUTTYGEN.EXE which in fact can generate private/public key for authentication. Here are the steps:

1. Double-click on puttygen.exe

At the bottom of the dialog box, under “Parameters”:

  • Make sure the type of key to generate is “SSH-2 RSA”
  • Set the number of bits to 2048

2. Click on “Generate”. Move the mouse randomly over the blank area until the progress bar reaches 100%

    Key comment:        [Your Name <your@email.address>   ]
    Key passphrase:     [chooose a passphrase             ]
    Confirm passphrase: [choose same passphrase           ]

The passphrase is used to keep your private key encrypted on disk. It can be pretty much anything you want and as long as you want – including spaces – but if you forget it, your key becomes worthless. For now pick something that you will easily remember. You can change it at any time you want in the future.

3. Click “Save public key”. Give a filename of “id_rsa.pub” (please save files into the same directory as where the executables are)

4. Click “Save private key”. Give a filename of “id_rsa.ppk”

5. Use the mouse to highlight all the text in the box “Public key for pasting into OpenSSH authorized_keys file”, and copy it to the clipboard.

6. Open up notepad, and paste the key file into the clipboard, and save this as “id_rsa.pub.openssh”. Now if you need an OpenSSH formatted key you can retrieve it from this file.

7. Exit puttygen.

NOTE: Key generation is a one-off exercise. The more you deploy your public key, the more work it to be if you were to lose it and have to start again with a new one. Thus it is important to make sure you don’t lose access to your private key. I suggest you keep a secure backup of the private key somewhere, e.g. on a CD-ROM that you lock away.

This information is available with more details at: https://nsrc.org/workshops/2015/drukren-nsrc/raw-attachment/wiki/Track2Agenda/exercise-ssh-key.htm

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.