ssh 使用公钥登录问题(publickeys, Permission denied error)

状况描述:

1、新装系统服务器,直接mkdir .ssh 文件,并赋予700权限,copy到.ssh目录下公钥及密钥,客户端不能正常登录。

2、ssh-keygen 命令执行下来,.ssh文件生成。copy公钥及密钥到.ssh目录下,客户端正常登录

3、less /var/log/messages

Apr 20 00:16:12 vb-fc14-0 setroubleshoot: SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys.

For complete SELinux messages. run sealert -l 174e87e8-bec5-4ae6-840c-44994ad5e2b3

$ sealert -l 174e87e8-bec5-4ae6-840c-44994ad5e2b3

SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys.

Plugin sshd_root (91.4 confidence) suggests:

If you want to allow sshd to have read access on the authorized_keys file Then you must fix the labels. Do: /sbin/restorecon -Rv /root/.ssh

Plugin catchall (9.59 confidence) suggests:

If you believe that sshd should be allowed read access on the authorized_keys file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing:

$ grep sshd /var/log/audit/audit.log | audit2allow -M mypol
$ semodule -i mypol.pp

4、SELinux惹的祸,关闭SELinux解决问题
a、暂时关闭(重启后恢复)

setenforce 0

b、永久关闭(需要重启)

vi /etc/selinux/config
SELINUX=disabled

 

此条目发表在技术生涯分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注