hdoop创建ssh互信

创建ssh互信

生成ssh互信过程:
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp -P222 authorized_keys hadoop2:~/.ssh/
scp -P222 authorized_keys hadoop3:~/.ssh/
scp -P222 authorized_keys hadoop4:~/.ssh/
ssh -p 222 hadoop2
ssh -p 222 hadoop3
ssh -p 222 hadoop4
以debug模式验证
ssh -v -p 222 hadoop2
到对方机器,vi /var/log/secure 命令,发现有
Authentication refused: bad ownership or modes for file /home/hadoop/.ssh/authorized_keys
在对方机器上,检查OpenSSH服务端的配置
OpenSSH的配置通常保存在:/etc/ssh/sshd_config
PermitRootLogin no  # 禁止root用户登陆
StrictModes yes  # 检查密钥的用户和权限是否正确,默认打开的
RSAAuthentication yes        # 启用 RSA 认证
AuthorizedKeysFile     .ssh/authorized_keys   # 验证公钥的存放路径
PubkeyAuthentication yes     # 启用公钥认证
PasswordAuthentication no    # 禁止密码认证,默认是打开的。

说明:
a)如果StrictModes为yes,而authorized_keys的权限为664等的情况,则验证密钥的时候,会报错:
引用
bad ownership or modes for file /home/linuxing/.ssh/authorized_keys

b)若PasswordAuthentication设置为no,则禁用密码认证,配合启动公钥认证,是更安全的方式。

执行 service sshd restart

猜你喜欢

转载自bjmike.iteye.com/blog/1826218