问题原文
原帖链接 · Sol · CC BY-SA 3.0
I've got a CentOS 7 server. I've set up /root/.ssh/authorized_keys on the host I'm trying to login to without a password. (Yes, allowing remote root access is a bad idea but this is an internal server.) ssh fails and there's this in the selinux audit log.
type=USER_LOGIN msg=audit(1494544798.597:481313): pid=18660 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=login acct="root" exe="/usr/sbin/sshd" hostname=? addr=xx.xx.xx.xx terminal=ssh res=failed'
Here are the permissions and context of the .ssh stuff:
# ls -aZ /root/.ssh
drwx------. root root system_u:object_r:ssh_home_t:s0 .
dr-xr-x---. root root system_u:object_r:admin_home_t:s0 ..
-rw-------. root root system_u:object_r:ssh_home_t:s0 authorized_keys
-rw-r--r--. root root unconfined_u:object_r:ssh_home_t:s0 known_hosts
I've compared the permissions and contexts to those of another system that allows ssh login without a password and they're the same.
In the audit message there's no indication of what file selinux is concerned about, just "res=fail".
In the system that works the log entry has this in it:
subj=system_u:system_r:sshd_t:s0-s0:c0.c1023
So, I'm confused. There is no file in /root/.ssh that has context system_u:system_r:sshd_t. So, I don't understand why that context is logged.
Is there a way to know what the context of all .ssh-related files should be? Yes, I've played with restorecon with no luck.
已采纳解答
原帖链接 · mdpc · CC BY-SA 3.0
You are quick to jump on SELinux....are you sure you have /etc/ssh/sshd_config properly set to allow root access via ssh? Have you restarted the sshd service if you have made any changes to the configuration files.
Have you tried setting SELinux to permissive and testing this.
You know, if SELinux was denying access I'd expect to see some type of AVC (Access Vector Cache) error in the /var/log/audit/audit.log. Remember that the audit.log is used for more than just SELinux issues. Thus all you are getting is simply a failed login report NOT an SELinux error.
Are you absolutely sure that the public/private openssh key pair you have actually works in an ssh context. You can try logging using the ssh command with -v option(s) to debug this and see.
I'd also be checking the /var/log/messages and /var/log/secure files for more information.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
