ssh登录配置公钥后仍然需要密码登录的问题处理

可以执行此命令看事件:

tail -f /var/log/messages

如果看到有说不能访问 ~/.ssh/authorized_keys 这个文件的,可以尝试下修改.ssh目录的权限为700authorized_keys 文件的权限为 600

如果是 selinux 限制了访问,例如

Feb  9 16:04:20 localhost python: SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys.#012#012*****  Plugin catchall (100. confidence) suggests   **************************#012#012If you believe that sshd should be allowed read access on the authorized_keys file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'sshd' --raw | audit2allow -M my-sshd#012# semodule -i my-sshd.pp#012

则可以按照日志中的提示执行

ausearch -c 'sshd' --raw | audit2allow -M my-sshd
semodule -i my-sshd.pp
/sbin/restorecon -v ~/.ssh/authorized_keys

Leave a Comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据