ssh免密登录方法不生效?Authentication refused: bad ownership or modes for directory

机器A通过ssh登录机器B,方法有两种:

1、密码方式

2、密钥方式:

两种方式同时开启的时候,优先使用密钥方式。

密钥登录方式的配置方法是,首先在登录机器B上创建文件authorized_keys(touch authorized_keys);其次正确设置文件authorized_keys的权限,一般是chmod -0600 authorized_keys,注意这里的权限设置

 
如果希望ssh公钥生效需满足至少下面3个条件:
1)  .ssh目录的权限必须是700 
2) .ssh/authorized_keys文件权限必须是600
3) 用户目录权限为 755 或者 700,就是不能是77x。
 
 
登陆目标机器,查看sshd的日志信息。日志信息目录为,/var/log/secure
 
参考:
https://www.bo56.com/ssh%E5%85%8D%E5%AF%86%E7%A0%81%E7%99%BB%E9%99%86%E8%AE%BE%E7%BD%AE%E6%97%B6authentication-refused-bad-ownership-or-modes%E9%94%99%E8%AF%AF%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/
原文地址:https://www.cnblogs.com/shengulong/p/6709743.html