Configure SSH server to login with Key-Pair Authentication. Create a private key for client and a public key for server to do it.

Create Key-Pair by each user, so login with a common user on SSH Server Host and work like follows.

# create key-pair
ubuntu@dlp:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): # Enter or input changes if you want
Enter passphrase (empty for no passphrase): # set passphrase (if set no passphrase, Enter with empty)
Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa
Your public key has been saved in /home/ubuntu/.ssh/
The key fingerprint is:
SHA256:Sy81HjIIQhqVHeVoxBxfV/JEflv16yS7wl3TXBafBaw [email protected]
The key's randomart image is:
ubuntu@dlp:~$ ll ~/.ssh
total 16
drwx------ 2 ubuntu ubuntu 4096 Apr 25 04:37 ./
drwxr-x--- 4 ubuntu ubuntu 4096 Apr 22 13:33 ../
-rw------- 1 ubuntu ubuntu 0 Apr 22 13:31 authorized_keys
-rw------- 1 ubuntu ubuntu 2655 Apr 25 04:37 id_rsa
-rw-r--r-- 1 ubuntu ubuntu 574 Apr 25 04:37
ubuntu@dlp:~$ cat ~/.ssh/ >> ~/.ssh/authorized_keys 

Transfer the private key created on the Server to a Client, then it’s possible to login with Key-Pair authentication.

ubuntu@node01:~$ mkdir ~/.ssh
ubuntu@node01:~$ chmod 700 ~/.ssh
# transfer the private key to the local ssh directory
ubuntu@node01:~$ scp [email protected]:/home/ubuntu/.ssh/id_rsa ~/.ssh/
[email protected]'s password:
id_rsa 100% 2655 1.8MB/s 00:00
ubuntu@node01:~$ ssh [email protected]
Enter passphrase for key '/home/ubuntu/.ssh/id_rsa': # passphrase if you set
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-25-generic x86_64)
ubuntu@dlp:~$ # logined

If you set [PasswordAuthentication no], it’s more secure.

root@dlp:~# vi /etc/ssh/sshd_config
# line 57 : change to [no]
PasswordAuthentication no
root@dlp:~# systemctl restart ssh