Search code examples
sshnfsselinux

SELinux prevents ssh with RSA key


I forgot that I had enabled SELinux on one of my web servers. So when I went to log into the host with my user account and ssh key, I was getting permission denied errors.

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

Hmmm... So I consoled into the server and was able to login. I tailed the audit logs, and this is what I saw:

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'

In googling for the answer to this I got the advice to run this command:

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

But when I go to login again, after doing that, I get the same result. Permission denied and the same error in the logs.

The only other thing I can think of is that the home directory for the user is mounted from an NFS share. Might there be some SELinux incantation I can use to allow SSH to a home directory on an NFS share?

Or maybe I'm missing something else?

Thanks, Tim


Solution

  • If restorecon didn't work, I generally try audit2why and/or audit2allow to find what policy is being violated. That's not to say that I apply the policy change suggestions that are generated, just that they lead to very good information to resolving the issue.