Now that we have our new user created, we can create an additional layer of security for our server, by creating a Cryptographic Key Pair. The key pair replaces the role of our login password.
It reduces the likelihood of success of "brute-force" attacks on the server. A brute-force attack is when someone trying to gain unauthorized access to your system, sets up a script to try different combinations of characters to guess your password.
If you are on a Windows machine you can follow the steps in this lesson.
If you are using Terminal on a MAC, please view the next lesson intended for MAC users.
First, open PuTTY Key Generator. Remember, we saved this application to the desktop when we downloaded it from putty.org.
On the Putty Key Generator interface, make sure you select "RSA" under "Type of key to Generate".
For "Number of Bits", type in 2048.
Now click the "Generate" button.
Copy the text under the heading "Public Key".
Create a folder on your desktop called "keys". Next create a text file in this folder and name it public.txt.
Paste the text into this file and save.
Now back in PuTTY Key Generator, type a key passphrase into the text field and confirm it. Do not forget this passphrase. You will need it later.
Click "Save Private Key", and save the file in your keys folder as "private.ppk".
Now exit your current session.
Load the MyLinode connection, but do not click open yet.
Expand the SSH menu on the left.
Click on Auth.
Click the Browse button, and locate the private.ppk file we created earlier.
Now go back to session under the "Category" menu.
Login as user bob.
We need to create an Authorized Keys file and enter our public key into this file.
Type in the following command to create a blank authorized_keys file inside a new folder called .ssh.
mkdir ~/.ssh; touch ~/.ssh/authorized_keys; chmod 700 ~/.ssh
Open the authorized_keys file using nano:
Open the public.txt file saved in your keys folder. Copy the text inside the file and paste it into nano editor.
To paste, just hit the right click button on your mouse.
Now press CTRL/CMD + X to exit. When prompted, type y to save the changes.
Now type exit to exit the session.
Reconnect using PuTTY.
You will now be asked to enter your passphrase. Enter it, and you are now connected using the SSH key.