To configure SSH key authentication, you need generate key pair and add a public key on the server.
Keys can be used, for example, when connecting via SSH or when setting up a connection in WinSCP.
After migrations or transferring a hosting account to another server for technical reasons when connecting via SSH errors may occur “REMOTE HOST IDENTIFICATION HAS CHANGED"And"POSSIBLE DNS SPOOFING". You can fix the situation using the instructions in the articles with descriptions of these errors.
You can generate a key pair in any of the following ways:
To generate a key pair in the console, do the following:
.ssh
by running the command:cd %userprofile%\.ssh
If the directory does not exist, create it with the command:
mkdir %userprofile%\.ssh
cd ~/.ssh
If the directory does not exist, create it with the command:
mkdir ~/.ssh
ssh-keygen -t rsa -b 2048
The program will ask you to specify a file name for saving keys and ask you to enter a secret phrase. Click on Enterto use the default options and the default filename id_rsa
(if you provide your own filename, use it in all subsequent commands instead of id_rsa
). Remember the output of the line “The key fingerprint is:».
Keys with default parameters will be saved in a subdirectory .ssh
user's home directory. These will be two files:
id_rsa
- private key.id_rsa.pub
- public key.type %userprofile%\.ssh\id_rsa.pub
cat ~/.ssh/id_rsa.pub
To add a public key on the server, do the following: