SSH keys can be used to create reliable and secure connections to the server without any problems. The peculiarity of the key is that it is almost impossible to crack, which is not the case with the usual password. Hence the question arises, where to get an SSH-key? It must be generated. How to do it? Let's tell you further.
The first thing we need to do is to open a terminal and run the command:
$ sh-keygen -t rsa
The user will get the following response:
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Press Enter on the keyboard in response, after which the operating system will prompt the user to enter a code word in order to provide additional security for the SSH connection. The console will say:
Enter passphrase (empty for no passphrase):
In principle, you can skip this step. The answer to this and subsequent questions will be simply pressing the Enter key on your keyboard.
Next, the key will be generated. The following message will be sent to the console:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
476:b2:a8:7f:08:b4:c0:af:81:25:7e:21:48:01:0e:98 user@localhost
The key's randomart image is:
+--[ RSA 2048]----+
|+.o. |
|ooE |
|oo |
|o.+.. |
|.+.+.. S . |
|....+ o + |
| .o .... |
| . .. . |
| .... |
+-----------------+
Now in the terminal execute the following command:
$ cat ~/.ssh/id_rsa.pub
The console will receive the key, which should be copied and pasted into the appropriate field:
At the end just click the "Add" button. After the key is added, we execute another simple command:
$ ssh root@[server-IP-address]
A connection to the server will be established, you do not need to enter a password.
In the Windows operating system you can also generate SSH-keys and establish a connection to a remote server via SSH, but for this you need to download and install one of the clients. For example, a good choice would be a client called Putty. You can download it from the official website of the developer.
This client does not need to be installed, just unzip the archive and start working. After unzipping, run the puttygen.exe
file. Select the SSH-2 RSA key type and length of 2048 bits and then click on Generate:
While generating the key, move the cursor in an empty area of the window (pseudo-randomization creation):
Finally, save the pair of keys on your computer by clicking Save public key and Save private key. Then paste the generated key into the corresponding field.
That's all. Now you know how to create an encrypted protocol for communication with the server: via SSH-key on Linux/MacOS and Windows. In the future, you will be able to log in without using your account password.
Apply the discount by inserting the promo code in the special field at checkout: