(1)输入“ssh-keygen -t rsa”,接着按三次“Enter”键。
生成私有密钥id_rsa和公有密钥id_rsa.pub两个文件。
ssh-keygen用来生成RSA类型的密钥以及管理该密钥,参数“-”用于指定要创建的SSH密钥的类型为RSA
(2)用 ssh-copy-id 将公钥复制到远程机器中。
ssh-copy-id -i /root/.ssh/id_rsa.pub master
//依次输入yes, root用户的密码
ssh-copy-id -i /root/.ssh/id_rsa.pub slave1
//依次输入yes, root用户的密码
ssh-copy-id -i /root/.ssh/id_rsa.pub slave2
//依次输入