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. Install OpenSSH You need to install OpenSSH on your machine to create SSH Key from your Terminal. To do so,
- Download the .exe file and install it on your system.
2. 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 Windows
Launch Terminal by pressing ⊞ Win+R and type ‘cmd’ in the search field and press enter. A Terminal window will open.
In your Terminal type the command:
ssh-keygen -t rsa
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 (/home/john/.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 (/home/john/.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 (the second file in the above screenshot) 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.