使用yum install openssh-clients 安装命令
有的系统没有此命令 有的系统缺省 就包含这一条命令!
但是我的测试机没有发现此命令 只能这样安装!
这时有报错了
[root@node2 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub node1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh: Could not resolve hostname node1: Name or service not known
这是因为没有解析主机名
[root@node2 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.96 node1
192.168.1.108 node2
192.168.1.109 node3
ping node1
[root@node3 ~]# ping node1
PING node1 (192.168.1.96) 56(84) bytes of data.
64 bytes from node1 (192.168.1.96): icmp_seq=1 ttl=64 time=1.36 ms
64 bytes from node1 (192.168.1.96): icmp_seq=2 ttl=64 time=0.336 ms
64 bytes from node1 (192.168.1.96): icmp_seq=3 ttl=64 time=0.441 ms
64 bytes from node1 (192.168.1.96): icmp_seq=4 ttl=64 time=0.579 ms
64 bytes from node1 (192.168.1.96): icmp_seq=5 ttl=64 time=0.505 ms