linux-ssh互信配置及问题解决

配置免密登录

1. 执行命令$ ssh-keygen -t rsa -P ""
回车后会在 ~/.ssh/ 下生成两个文件:id_rsa 和 id_rsa.pub,这两个文件是成对出现的

2. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

scp ~/.ssh/authorized_keys 中内容到所有你想相互免密的机器即可。

问题解决

查看系统安全日志

less /var/log/secure

error: Received disconnect from 101.10.1.1: 3: com.jcraft.jsch.JSchException: Auth fail [preauth]
Dec 18 14:19:03 hdp111 sshd[8915]: Authentication refused: bad ownership or modes for directory /home/work

定位问题原因:Authentication refused: bad ownership or modes for directory /home/work

SSH进行认证的过程中除了对用户目录有权限要求外,对 .ssh 文件夹和 authorized_keys 文件同样也要限制。

解决方法:

chmod g-w /home/work
chmod 700 ./.ssh 
chmod 600 ~/.ssh/authorized_keys
发布了81 篇原创文章 · 获赞 29 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/breakout_alex/article/details/103597164