How to configure SSH without a password with a key pair in Ubuntu

Create a key pair, leave all values by default:

ssh-keygen

In the console, enter a command that configures the server so that you can sign in with an SSH key:

 ssh-copy-id -i .ssh/id_rsa.pub [email protected] 

Instead of127.0.0.1, specify the IP server.

Take the private key id_rsa rename the extension in PPK, winscp add to the connection SSH authentication and it will offer to convert the file to Putty format and save a new key. and add a new key to the connection, try to connect.

Edit the Sshd_config file

mcedit /etc/ssh/sshd_config

Add the PasswordAuthentication no instruction

Immediately you can change the standard access port, the Port 22  instruction, for example, write Port 4321, now access to SSH will be on port 4321.

Reboot ssh to apply config changes:

systemctl restart ssh

Now when you try to log in by password, we get a window with an error:

Attach a private key to the connection and the task is solved.