it is so comfortable to avoid using a password to get ssh access
On source machine – whre you wish to connect from we generate ssh key pair:
~$ cd .ssh
~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/lab4/.ssh/id_rsa): 103host
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in 103host.
Your public key has been saved in 103host.pub.
The key fingerprint is:
The key's randomart image is:
| . |
| . . |
| . . . o o |
| o o o E + |
| S . . = o|
| . o..oO+|
| o .o**%|
So, we have had gotten key pair like these:
~/.ssh$ ls -la
drwx------ 2 lab4 lab4 4096 Jun 7 09:44 .
drwxr-xr-x 17 lab4 lab4 4096 Jun 7 09:38 ..
-rw------- 1 lab4 lab4 1675 Jun 7 09:44 id_rsa
-rw-r--r-- 1 lab4 lab4 393 Jun 7 09:43 id_rsa.pub
Now we have to copy *.pub key to the host to which we want to have got passwordless access:
~/.ssh$ ssh-copy-id email@example.com
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/lab4/.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
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'firstname.lastname@example.org'"
and check to make sure that only the key(s) you wanted were added.
Do not foget to turn off passphrase every time when we run ssh connection:
Finaly, we have got ability to get access without password but with the key file:
~$ ssh email@example.com
Last login: Sun Jun 7 09:39:41 2020 from 192.168.1.101