1、从各个节点生成公钥 ssh-keygen -t rsa -P '' 一路回车
2、从各个节点拷贝id-rsa.pub到主节点:
scp /root/.ssh/id_rsa.pub root@master1:/root/.ssh/id_rsa.pub.node1
scp /root/.ssh/id_rsa.pub root@master1:/root/.ssh/id_rsa.pub.node2
scp /root/.ssh/id_rsa.pub root@master1:/root/.ssh/id_rsa.pub.node3
scp /root/.ssh/id_rsa.pub root@master1:/root/.ssh/id_rsa.pub.node4
3追加到authorized_keys
cat /root/.ssh/id_rsa.pub.node1>> /root/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub.node2>> /root/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub.node3>> /root/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub.node4>> /root/.ssh/authorized_keys
4将authorized_keys复制到所有节点
scp /root/.ssh/authorized_keys root@node1:/root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@node2:/root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@node3:/root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@node4:/root/.ssh/authorized_keys