This post is probably as much for me as it is everyone else. I got sick of having to look up 3 or 4 different SSH keygen tutorials every time I needed to generate a private/public SSH key pair, so I thought I’d write up my own. Here’s how to make your own SSH keys at a shell prompt (i.e. Linux):
That’s all there is to it! Please be sure to keep the id_rsa file safe, and don’t ever share it with anyone unless you want them to log into the account. You should protect the private keyfile in the same manner you would protect any password.
You may get an error on the client machine that says
Could not open a connection to your authentication agent. If you see this message, run the following command:
exec ssh-agent bash
That will start the ssh agent and allow you to connect to it so that you can add the new key.
Alternate Step 2 for Windows Clients
If your client is a Windows machine, you’re probably using PuTTY to connect to the host. If that is the case, step 2 will be different for you and you’ll want to use PuTTYgen to import the key.
Just launch PuTTYgen, click Conversions and then Import key.
Then click Save private key and you’re done!
Connecting to an SSH Host with PuTTY
You should be able to use the key to connect to the host from PuTTY. Just start up PuTTY, load your saved session or enter the host info, go to Connection > SSH > Auth and browse to the private key (.ppk file) you just saved.