setup1:准备环境
在ns1.benet.com上:[root@ns1 ~]# hostname ns1.benet.com
[root@ns1 ~]# vi /etc/hosts192.168.4.11 ns1.benet.com ns1192.168.4.22 ns2.benet.com ns2 在ns2.benet.com上:[root@ns2 ~]# hostname ns2.benet.com
[root@ns2 ~]# vi /etc/hosts192.168.4.11 ns1.benet.com ns1192.168.4.22 ns2.benet.com ns2=================================================================================
setup2:创建密钥对在ns1.benet.com上:
[root@ns1 ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'.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:80:21:85:60:ed:76:8c:d8:b3:4f:a8:6e:ae:fb:b5:65 [root@ns1 ~]# ls .ssh/id_rsa id_rsa.pub在ns2.benet.com上:
[root@ns2 ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'.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:3a:d0:27:fd:3c:55:74:15:29:fe:c8:9f:4b:87:c5:96 [root@ns2 ~]# ls .ssh/id_rsa id_rsa.pub=================================================================================
setup3:建立通信信任在ns1.benet.com上:
[root@ns1 ~]# cat ~root/.ssh/id_rsa.pub > ~root/.ssh/authorized_keys[root@ns1 ~]# ssh cat ~root/.ssh/id_rsa.pub >> ~root/.ssh/authorized_keysThe authenticity of host 'ns2.benet.com (192.168.4.22)' can't be established.RSA key fingerprint is 6e:9d:7a:2d:98:87:46:f1:48:47:f4:04:62:b6:29:4b.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'ns2.benet.com,192.168.4.22' (RSA) to the list of known hosts. password: [root@ns1 ~]# scp ~root/.ssh/authorized_keys password: authorized_keys 100% 800 0.8KB/s 00:00=================================================================================
setup4:验证通信通道是否打通在ns1.benet.com上:
[root@ns1 ~]# ssh hostnamens2.benet.com在ns2.benet.com上:
[root@ns2 ~]# ssh hostnamens1.benet.com