ssh免密登录不生效

ssh免密登录不生效

   张吉吉     2020年11月5日 09:10     1903    

1.设置免密登录

ssh-keygen

ssh-copy-id root@192.168.0.215

已经将生成的id_rsa.pub发送到了指定服务器。

 

2.问题与排查

但是当ssh 192.168.0.215依旧提示输入密码

因为登录的日志一般都会在/var/log/secure中生成,于是在日志中找到了如下错误

Authentication refused: bad ownership or modes for file /root/.ssh/authorized_keys

Authentication refused: bad ownership or modes for directory /root

上边的错误信息就是因为authorized_keys文件和root目录权限的问题。

 

3.解决办法

sshd为了安全,对属主的目录和文件权限有所要求。

如果权限不对,则ssh的免密码登陆不生效。
用户目录权限为 755 或者 700,就是不能是77x
.ssh目录权限一般为755或者700
rsa_id.pub authorized_keys权限一般为644
rsa_id权限必须为600


文章评论

0

其他文章