准备两台主机
192.168.191.133 192.168.191.121
先在133主机上生成密钥信息
[root@zabbix ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa Generating public/private rsa key pair. 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: 6f:0f:05:55:26:31:88:13:b7:99:aa:27:4b:d5:10:96 root@zabbix The key's randomart image is: +--[ RSA 2048]----+ | ++..=oo | | .Eo.= + | | ..= | | + . | | S . . | | o . . | | + . + | | . + . o | | . . | +-----------------+
2.生成验证文件:authorized_key
[root@es .ssh]# cat id_rsa.pub >> authorized_keys [root@es .ssh]# ll total 16 -rw------- 1 root root 389 Apr 25 05:33 authorized_keys -rw------- 1 root root 1675 Apr 24 21:52 id_rsa -rw-r--r-- 1 root root 389 Apr 24 21:52 id_rsa.pub -rw-r--r-- 1 root root 531 Apr 25 05:26 known_hosts
3.拷贝密钥对和认证文件到121上
[root@es .ssh]#scp id_rsa* root@192.168.191.121/root/.ssh [root@es .ssh]#scp authorized_keys root@192.168.191.121/root/.ssh