SSH免密登陆
1.每台都要设置
mkdir ~/.ssh
chmod 700 ~/.ssh
vi /etc/ssh/sshd_config
内容:
RSAAuthentication yes # 启用 RSA 认证
PubkeyAuthentication yes # 启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys # 公钥文件路径(和下面生成的文件同)
2.master上生产密钥
ssh-keygen -t rsa -P ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
service sshd restart
scp ~/.ssh/id_rsa.pub root@slave1.hadoop:~/.ssh
scp ~/.ssh/id_rsa.pub root@slave2.hadoop:~/.ssh
3.每台slave上执行
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
rm -r ~/.ssh/id_rsa.pub
4.master上测试
ssh slave1.hadoop
exit
ssh slave2.hadoop
exit