CentOS SSH免密登陆

前端之家收集整理的这篇文章主要介绍了CentOS SSH免密登陆前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

猜你在找的CentOS相关文章