How to create a SSH key from a Unix(Linux/Mac) machine

M
Muthurengan 6 years ago - Created

The SSH keys are a key pair made between your computer and the server that allows the server to connect if it sees the matching key on the machine from which you are logging in. While a password can eventually be cracked with a brute force attack, SSH keys are nearly impossible to decipher by brute force alone. SSH keys provide more security than using a password.


1. Create the key pair

The first step is to create the key pair on your computer. To do so, launch your Terminal window.

In your Mac

Launch Terminal by pressing +Space and start typing ‘terminal’ in the search field until Terminal icon appears. Double Terminal. A Terminal window will open.

In your Linux machine

Launch Terminal by typing Control + Alt + T.

In your Terminal type the command:

ssh-keygen -t rsa   

2. Store the Keys and Passphrase

Once you have entered the above command, you will get a few more questions:

Enter file in which to save the key (/Users/amal/.ssh/id_rsa):

The path at the end is the the location where your keys will be stored. Give a name for the file which will store your keys and press Enter. In this demo I have given the name “mysshkey”.

Enter file in which to save the key (/Users/amal/.ssh/id_rsa): mysshkey

Once you press Enter, it will ask for a passphrase which is other words in a password for your keys.

Enter passphrase (empty for no passphrase):

Type a password and press Enter. It will ask you to retype the password. Once you retype the password and press Enter again, your keys will be generated in the path.


If you go to the location where the keys are saved, you’ll find two files.


The file with the .pub extension has the public key and the other file has the private key. Open the files with a text editor to copy the key inside them.


Was this article helpful?

0 out of 0 found this helpful

Articles in this section