前提是已经配置过hosts文件,以及更改别名
1.以rosense账户登陆,先执行下列语句,生成秘钥
ssh-keygen -t rsa
2.master生成一个文件
touch ~/.ssh/authorized_keys
3. 以rosense账号登录slave227机器,执行以下命令,即可将slave227的公钥传输到master机器,文件名为slave.id_rsa.pub
scp ~/.ssh/id_rsa.pub rosense@master:~/.ssh/slave.id_rsa.pub
4.在master上执行下列
cat ~/.ssh/slave.id_rsa.pub >> ~/.ssh/authorized_keys
5.同步master上的秘钥到slave227
scp ~/.ssh/authorized_keys rosense@slave227:~/.ssh/
6.授权
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
7.验证
ssh slave227