You can log into the Linux server console remotely without using a password. To do this, you need to use the SSH authentication method using RSA keys.
This method is more convenient and safer to use.

This article describes the setup procedure if you are connecting from a computer with a Linux (or MacOS).

To configure the authentication method, follow these steps:

  • Run the command ssh-keygen in the bash console:

[user@homepc ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
SHA256:UPPm+FdPbJWWVbrNNuoGpk7xnD1w8LALMvjtKhbG4qo user@homepc
The key's randomart image is:
+---[RSA 3072]----+
|        o       +|
|       . o     .+|
|      .   oo  .+.|
|      .. +  = .=.|
|    .. oSo.o oo.B|
|   . +. +.=o*..=.|
|  . o .. o+=o+  .|
|   . o  o. ....  |
|E.. . ..oo  ..   |
+----[SHA256]-----+

As a result, two files will be generated in the ~/.ssh folder

  • Private key file - id_rsa
  • Public key file - id_rsa.pub

Attention! The private key file must be protected from unauthorized access. Make sure that this file is not compromised.

  • To save or update the key fingerprint, run the command ssh-keyscan x.x.x.x >>~/.ssh/known_hosts

Hereinafter x.x.x.x - is the IP address of your server on the hosting

[user@homepc ~]$ ssh-keyscan x.x.x.x >>~/.ssh/known_hosts
# x.x.x.x:22 SSH-2.0-OpenSSH_7.4
# x.x.x.x:22 SSH-2.0-OpenSSH_7.4
# x.x.x.x:22 SSH-2.0-OpenSSH_7.4

  • Run the command ssh-copy-id@x.x.x.x and enter the root password you received when you activated the server on the hosting

[user@homepc ~]$ ssh-copy-id root@91.238.103.8
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@91.238.103.8's password: ********

  • If the password you entered is correct, the setup procedure is complete. Further, you can connect to the VPS server on the hosting without entering a password using the command in the console:

[user@homepc ~]$ ssh root@x.x.x.x

To configure SSH connection under Windows OS, see Knowledge Base article