SELinux 阻止使用 RSA 密钥的 ssh

SELinux prevents ssh with RSA key

我忘记了我在我的一个网络服务器上启用了 SELinux。因此,当我使用我的用户帐户和 ssh 密钥登录主机时,出现权限被拒绝的错误。

[TimothyDunphy@JEC206429674LM:~] #ssh bluethundr@web1.somedomain.com
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

嗯...所以我控制台进入服务器并能够登录。我跟踪了审计日志,这是我看到的:

type=USER_LOGIN msg=audit(1429981690.809:394593): pid=17074 uid=0     auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023     msg='op=login acct="bluethundr" exe="/usr/sbin/sshd" hostname=? addr=47.18.111.100 terminal=ssh res=failed'

在谷歌搜索这个问题的答案时,我得到了 运行 这个命令的建议:

[root@web1:~] #restorecon -R -v /home/bluethundr/.ssh
[root@web1:~] #

但是当我再次登录时,我得到了同样的结果。权限被拒绝,日志中出现相同的错误。

我唯一能想到的是用户的主目录是从 NFS 共享挂载的。可能有一些 SELinux 咒语我可以用来允许 SSH 到 NFS 共享上的主目录?

或者我还遗漏了什么?

谢谢, 蒂姆

如果 restorecon 不起作用,我通常会尝试 audit2why and/or audit2allow 来查找违反了哪些政策。这并不是说我应用了生成的政策更改建议,只是它们会为解决问题提供非常好的信息。

宾果!!

当我 运行 audit2why -w 这是我看到的输出:

 [root@web1:~] #grep ssh /var/log/audit/audit.log | audit2why -w
 Was caused by:
    The boolean use_nfs_home_dirs was set incorrectly.
    Description:
    Allow use to nfs home dirs

    Allow access by executing:
    # setsebool -P use_nfs_home_dirs 1
    type=AVC msg=audit(1429983513.529:394784): avc:  denied  { read } for  pid=19748 comm="sshd" name="authorized_keys" dev="0:40" ino=275968 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:nfs_t:s0 tclass=file

看来我的预感是关于 NFS 的,你建议使用 audit2why 让我破案!

[TimothyDunphy@JEC206429674LM:~/creds] #ssh bluethundr@web1.jokefire.com
Last login: Sat Apr 25 13:41:02 2015 from ool-2f126f64.dyn.optonline.net
[bluethundr@web1 ~]$

砰!!有用。感谢您的帮助!