发现一台机器虽然建立了信任关系,但是仍然无法通过信任关系登陆,检查了很多地方。。。。
1、~/.ssh 目录权限
2、~/.ssh/里面文件的权限
3、重新在客户端生成了公钥,传到该服务器端,仍无法信任关系登陆
4、检查了/etc/ssh/sshd_config 文件的内容
5、差点要重启sshd(怕影响别人,未遂)
6、baidu search
等等都没有结果
-------------------------------------------华丽的解决-------------------------------------------
突然去看了下 /var/log/secure 日志,哇,终于找到了原因,原来是用户的主目录权限不符合要求,chmod之后OK
/var/log/secure 日志:
Authentication refused: bad ownership or modes for directory /home/git/.ssh
想来应该是文件夹读写权限的设置问题.在Google之后,找到下面这个web,与所遇问题是类似的:
SSH Authentication Refused: Bad Ownership or Modes for Directory
下面转贴来自其中的一段内容:
SSH doesn’t like it if your home or ~/.ssh directories have group write permissions. Your home directory should be writable only by you, ~/.ssh should be 700, and authorized_keys should be 600
You can also get around this by adding StrictModes off to your ssh_config file, but I’d advise against it - fixing permissions is the way to go.
------------------------------------------- end --------------------------------------------------