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:
- Download & run Puttygen[chiark.greenend.org.uk]
- Pick the type of key you want to generate (At the bottom in the Parameters) section
- Pick the number of bits in the key
- Press the Generate button
- Move your mouse around to generate some randomness
- You can set a passphrase and save public / private keys
That's it- your done!
Generate SSH Keypairs using OpenSSH:
- 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) - Run through the ssh-keygen wizard by running a command with this syntax:
- ssh-keygen -b <number_of_bits> -t <type_of_key> -C "<Key_Comment_Here>"
- Enter a File name where you want to save the key
- Enter a passphrase if you want one
- The Private and public keys are saved and you should see the fingerprint along with the keys randomart image
- 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) - 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"