已经安装好的2台linux
假设有两台服务器 server(192.168.16.10) 和client(192.168.16.11),现在需要client可以免密登陆server.
在服务器client上创建密钥(命令运行中一路回车即可)[root@client ~]# 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:b7:01:7d:f7:51:73:c4:f2:3c:6c:61:fa:ae:f9:d6:ea root@clientThe key's randomart image is:+--[ RSA 2048]----+| ++|| . .o=|| . . . ==.|| . . o =+|| S o o o|| . o . || . . .|| .o.|| +Eo |+-----------------+
在服务器server上加入密钥(过程中选yes并输入client的密码一次)[root@server ~]# ssh client cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keysThe authenticity of host 'client (192.168.16.11)' can't be established.RSA key fingerprint is 8d:88:19:2d:a9:15:e1:f6:3e:c9:0e:48:53:cf:8c:f7.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'client ' (RSA) to the list of known hosts.root@client 's password:
在服务器client上验证登陆server(成功)[root@client ~]# ssh serverLast login: Sat Apr 15 08:40:18 2017 from client
