ssh免密码登陆设置时bad ownership or modes for file 报错的解决办法

问题:
密钥登陆时报如下错误:
May 13 10:11:26 keep sshd[25103]: Authentication refused: bad ownership or modes for file /home/git/.ssh/authorized_keys

原因:
sshd为了安全,对属主的目录和文件权限有所要求。如果权限不对,则ssh的免密码登陆不生效。
用户目录权限为 755 或者 700,就是不能是77x。
.ssh目录权限一般为755或者700。
rsa_id.pub 及authorized_keys权限一般为644
rsa_id权限必须为600

解决:
修改相应目录和文件的权限即可。

猜你喜欢

转载自blog.51cto.com/zengwj1949/2115650