SSH Passwordless Login Using SSH Keygen

 

Machine A:

Notice: Do not enter a passphrase.

~/.ssh$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/userA/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/userA/.ssh/id_rsa
Your public key has been saved in /home/userA/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:WWEQAjekpCJTtOzwezRmMTigVfFj1ef0JfiTZB9ecpU userA@machineA
The key’s randomart image is:
+—[RSA 3072]—-+
|..+.=+= ++o . +|
|.= = + + …+ =E+|
|* * + + .+ =.Bo|
|.* . + . o . =..|
| o = S . |
| = . |
| . . |
| . |
| |
+—-[SHA256]—–+
~/.ssh$ ls
id_rsa id_rsa.pub

 

Machine B:

Create a directory ~/.ssh (if it does not exist 🙂 ):

~/.ssh$ ssh userB@machineB mkdir -p .ssh
The authenticity of host ‘machineB (111.222.333.444)’ can’t be established.
RSA key fingerprint is SHA256:yngrwOAobBhLaPxgo0ORHWwKQXJW2ItyTXuuBcpA15w.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘machineB,111.222.333.444’ (RSA) to the list of known hosts.
userB@machineB’s password:

Copy a public key to  userB@machineB:.ssh/authorized_keys:

~/.ssh$ cat id_rsa.pub | ssh userB@machineB ‘cat >> .ssh/authorized_keys’
userB@machineB’s password:

You can try it

~/.ssh$ ssh userB@machineB