我搭建的7台机器,master,slaves1,node1,node2,node3,node4,node5
用户名是:hadoop,系统用的是centos6.5 64位
1、在master和各节点下的 /home/hadoop/.ssh 文件下执行了 ssh-keygen -t rsa
会产生文件:id_ras is_ras.pub两个文件
2、复制所有的slave服务器的公钥到master的.ssh目录下
在slave1机器上:scp ~/.ssh/id_rsa.pub hadoop@master:~/.ssh/slave1.pub
node1机器上:scp ~/.ssh/id_rsa.pub hadoop@master:~/.ssh/node1.pub
其他的节点一次类推。
3、在master服务器把所有服务器的公钥加入到用于认证的公钥文件:
[hadoop@master ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[hadoop@master ~]cat ~/.ssh/slave1.pub >> ~/.ssh/authorized_keys
4、对authorized_keys进行授权:
[hadoop@master ~]chmod 600 ~/.ssh/authorized_keys
.ssh文件要给予700的权限:chmod -R 700 /home/hadoop/.ssh
5、再将master的授权文件authorized_keys复制到到其他的机器上:
scp ~/.ssh/authorized_keys hadoop@slave1:/home/hadoop/.ssh/
scp ~/.ssh/authorized_keys hadoop@node1:/home/hadoop/.ssh/
scp ~/.ssh/authorized_keys hadoop@node2:/home/hadoop/.ssh/
scp ~/.ssh/authorized_keys hadoop@node3:/home/hadoop/.ssh/
scp ~/.ssh/authorized_keys hadoop@node4:/home/hadoop/.ssh/
scp ~/.ssh/authorized_keys hadoop@node5:/home/hadoop/.ssh/
master可以顺利进入到各个节点