First, generate a public private key pair
$ ssh-keygen -t rsa -p ' Generating public/private rsa key pair. enter file in which to save the key (/ROOT/.SSH/ID_RSA): Your identification has been saved in /root/.ssh/id_rsa. your public key has been saved in /root/.ssh/id_rsa.pub.the key Fingerprint is:88:64:ed:a1:a7:a2:c0:b4:ee:77:38:2f:c7:39:c6:c1 [email protected]the key ' s  RANDOMART IMAGE IS:+--[ RSA 2048]----+| | | . | | o o | | o + o | | . + + s | | o . e | |. o. = o | | o. * o | | Oo. b. |+-----------------+ -p phrase Provide old passphrase. this refers to the password that uses the private key -t type specify type of key to create. This is the type of public private key created $ ll .ssh/total 8 -RW-------. 1 root root 1675 sep 6 04:12 id_rsa-rw-r--r--. 1 root root 394 sep 6 04:12 id_rsa.pub
Second, copy the public key to password-free login machine
$ ssh-copy-id [Email protected]the authenticity of host ' 172.17.5.46 (172.17.5.46) ' can ' t be established. RSA Key fingerprint is 8e:ac:89:5d:10:be:e7:d8:a2:34:0b:bf:70:cd:ce:33.are your sure you want to continue connecting (yes/n o)? yeswarning:permanently added ' 172.17.5.46 ' (RSA) to the list of known hosts. [email protected] ' s Password:now try logging into the machine, with "ssh" [email protected] ' ", and check in:. Ssh/author Ized_keysto Make sure we haven ' t added extra keys and you weren ' t expecting.
Login-Free machine:
$ LL. ssh/total 4-RW-------. 1 root root 394 Sep 6 04:16 Authorized_keys
Third, testing
# SSH 172.17.5.46Last Login:sun Sep 6 04:06:43 from 172.17.5.45[[email protected] ~]#
Successful password-free login.
Iv. Conclusion
Password-free login does not have to enter the password every time, convenient many;
Rsync can also use SSH authentication to transfer files between Linux servers without password;
It is best not to configure password-free login for root user
SSH password-free login between Linux