#SSH无密码登录要使用公钥与私钥, a public/private key can be generated under Linux with Ssh-keygen; Server1 (192.168.4.101) Server2 (192.168.4.102) Server1 ssh password-free login Server2; #Server1生成. SSH directory [[email protected] /]# ssh 192.168.4.102The authenticity of host ' 192.168.4.102 ( 192.168.4.102) ' can ' t be established. Rsa key fingerprint is 01:ac:84:3f:a5:ae:2d:a6:f4:68:f6:3f:e4:6c:33:ec. are you sure you want to continue connecting (yes/no)? yesWarning : permanently added ' 192.168.4.102 ' (RSA) to the list of known hosts. [email protected] ' s password: #ctrl +c end off [[email protected] /]# #Server2生成. SSH directory [[email] protected] /]# ssh 192.168.4.101The authenticity of host ' 192.168.4.101 (192.168.4.101) ' can ' t be established. Rsa key fingerprint is 18:4c:a2:18:43:36:57:15:ea:87:6c:20:19:99:e1:b8. are you sure you want to continue connecting (yes/no)? yesWarning : permanently added ' 192.168.4.101 ' (RSA) to the list of known hosts. [email protected] ' s password: #ctrl +c end [[email protected] /]# #Server1生成公钥/private key [email protected] /]# ssh-keygen -t rsagenerating public/private rsa key pair. enter file in which to save the key (/ROOT/.SSH/ID_RSA): Enter passphrase (empty for no passphrase): enter same passphrase Again: 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:f4:45:f3:dc:f8:65:28:17:a8:e3:0a:84:24:ca:ea:c9 [email protected]the key ' s randomart IMAGE IS:+--[ RSA 2048]----+| o. | |   . .     &NBSP, .... + = | |. o . . .o * +| |.   .&NBSP, .... .o. o o.| |. . s... .| |. . . | | o . . . | | e . | | |+------ -----------+ #将Server1公钥复制到Server2并改名为authorized_keys [[email protected] /]# scp /root/.ssh/ Id_rsa.pub [email protected]:/root/.ssh/authorized_keys[email protected] ' s password: Id_rsa.pub 100% 406 0.4KB/s 00:00# log in to server2[[email protected] /]# ssh 192.168.4.102last from Server1 login: sat jul 11 01:19:59 2015 from 192.168.4.100# Direct password-free login [[email protected] ~]# #如果是普通用户免密码登录也是相同的, log in with a normal user, and then generate the key;
This article is from the "Wu Shanqiang" blog, make sure to keep this source http://shanqiangwu.blog.51cto.com/8067564/1673875
SSH Authentication Password-free login