Generate SSH Keypairs (Windows / NIX)


Brain dump: I recently generated some SSH Keypairs and wanted to document the process. While there are more than 10,000 pages out there that list this, I like knowing I can search my site for the steps that worked for me. :)

 

This covers how to use PuTTYGen and OpenSSH to generate keypairs

Generate SSH Keypairs on Windows using puttygen:


  1. Download & run Puttygen[chiark.greenend.org.uk]
    1-puttygen.png
  2. Pick the type of key you want to generate (At the bottom in the Parameters) section
  3. Pick the number of bits in the key
  4. Press the Generate button
  5. Move your mouse around to generate some randomness
    2-puttygen.png

  6. You can set a passphrase and save public / private keys
    3-puttygen.png

That's it- your done!

 

 

Generate SSH Keypairs using OpenSSH:

  1. Make sure you have a version of OpenSSH Installed on your system
    (For this article I'm using Cygwin on Windows. The syntax should work on other platforms)

  2.  Run through the ssh-keygen wizard by running a command with this syntax:
    1. ssh-keygen -b <number_of_bits> -t <type_of_key> -C "<Key_Comment_Here>"
    2. Enter a File name where you want to save the key
    3. Enter a passphrase if you want one
    4. The Private and public keys are saved and you should see the fingerprint along with the keys randomart image

  3. Here is a screenshot from my box of a sample key being generated using this command:

    ssh-keygen -b 1024 -t rsa1     (This generates a 1024 bit RSA1 key)

    ssh-keygen_rsa1.png

  4.  Here is another screenshot taken when I ran the command with the -C switch:

    ssh-keygen -b 1024 -t rsa1 -C "rsa1-ssh1-1024-pw"

    ssh-keygen_rsa1_2048.png