How to generate an SSH key on Linux or Mac


To generate a new SSH key on a Mac- or Linux machine, you first open up your terminal and execute the following command:

ssh-keygen -t rsa

You will be asked two questions, one of which is what file to save the key in: you can keep the default file name. Press enter.

You will also be asked for a passphrase. Many people use SSH keys to avoid having to typ in their passwords; However, if your SSH key manages to leak out, which can happen in all sorts of ways, the person who's obtained the key will be able to log in very easily. I recommend using a password, but if you handle these files with extreme caution, it's not absolutely necessary.

After you've answered these questions, two files will be generated. id_rsa and, the .pub file is your public key. The server or remote machine will use this file to validate if your personal key fits the public key; the other file is your personal key. 

The terminal will tell you where it put the newly generated keys. Most often you can change directory, in your terminal, to the .ssh folder using the following command:

cd ~/.ssh

Need help configuring your Cloud Container (or server) to use your newly generated SSH key? In this tutorial we expand on adding the key to your container.


Comments are turned off.