SSH Key Generation on Windows OSX and Ubuntu

SSH Key Generation on Windows, OSX, and Ubuntu

In this tutorial I’ll go over generating SSH keys on three popular operating systems, Windows, Mac OSX, and Ubuntu (Linux). Since I’ll be referencing SSH keys in many future posts, I should probably write a quick guide.

SSH Key generation on Ubuntu and Mac OSX

Open up terminal and run the following command to generate a Private/Public SSH key.


The prompt will ask you a few questions before generating the keys. If you want an extra layer of security you can add a passphrase to your key. This would require a “hacker” to need your private key and your passphrase in order to connect to whatever it is your connecting too.

Generating public/private rsa key pair.
Enter file in which to save the key (/home/robby/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/robby/.ssh/id_rsa.
Your public key has been saved in /home/robby/.ssh/
The key fingerprint is:
3e:0f:60:5e:25:33:a0:82:e3:65:60:14:91:87:d2:7d robby@HP-ENVY
The key's randomart image is:
+--[ RSA 2048]----+
| +=              |
|oo .             |
|ooo   .          |
|.o.. E .         |
|o...o + S        |
|..o. + * .       |
| .  .   +        |
|         +       |
|          .      |

This will save your public and private key in home/.ssh . The folder is hidden. To view it on Ubuntu you can press CTRL+H to display hidden folders.


In Mac OSX you can open finder and press command+g, enter ~/.ssh as the location. Here you will find your private and public keys.

osx go to folder

SSH Key generation on Windows with PuTTy

Windows is a pain in the ass when it comes to ssh. To connect via ssh and to use SSH key pairs we will need third-party software. PuTTy is pretty good and simple to use. Download PuTTy and PuTTygen from here.

Now open PuTTYgen, click Generate, and move your mouse over the blank area to generate ssh keys. Afterwords enter a key passphrase (if you want) and save your private key.


Since most servers are some form of linux, and use OpenSSH, we’ll need the key provided in the top box. Copy and paste the key and save it in a file called

To connect to a server using this key pair you’ll need to connect through PuTTy. Before connecting navigate to the SSH>Auth section and find your key.


  • March 5, 2016: Updated the OSX instructions.