Generate SSH Key on Linux, macOS and Windows

emanuel – February 15, 2019

This is a quick guide on how to generate an SSH key in Linux, macOS and Windows.

Creating an SSH key on Linux & macOS

Check for existing keys

Open the terminal an run the following command

cd ~/.ssh

If you see “No such file or directory”, then there aren’t any existing keys, go to step Generate new key

If you se existing key id_rsa.pub just run this command to get the key to your clipboard

pbcopy < ~/.ssh/id_rsa.pub

Then paste that to your profile page and save.

Generate a new key

If you dont have any existing keys then you need to crate a new pair. Start by open the terminal and run the following command

ssh-keygen -t rsa -C "your_email@example.com"

Just press <enter> to accept the default location.

Then you will be prompt to set a passphrase for your key, you can leave it empty but for security reasons, we recommend that you have a passphrase for your public key.

Then you are all set, just run this command in the terminal to store it in your clipboard ready to paste the key in your profile page.

pbcopy < ~/.ssh/id_rsa.pub

Creating an SSH key on Windows

Check for existing keys

Open a command prompt, and run:

cd %userprofile%/.ssh

If you see “No such file or directory”, then there aren’t any existing keys, go to step Generate a new key

If you se existing key id_rsa.pub just run this command to get the key to your clipboard

clip < id_rsa.pub

Then paste that to your profile page and save.

Generate a new key

If you don’t have an existing SSH key that you wish to use, generate one as follows:

Log in to your local computer as an administrator.

In a command prompt, run:

ssh-keygen -t rsa -C "your_email@example.com"

Note that the ssh-keygen command is only available if you have already installed Git (with Git Bash).

The first step, just press <enter> to accept the default location.

Then you will be prompt to set a passphrase for your key, you can leave it empty but for security reasons, we recommend that you have a passphrase for your public key.

When you are done you just run the following command to store it in your clipboard and ready to paste in your key on your profile page.

clip < id_rsa.pub


Similar articles