SELinux – Allow system_u and new SELinux user to log in via SSH

centos6selinux

I am new to SELinux and I am still trying to figure out how everything works but my goal is to create a Linux account associated with either system_u or a new SELinux user and try to ssh to my machine using that account. However, when I try to ssh to the machine in Enforcing mode using such an account I get the following message

Unable to get valid context for user

, even though I can still log in fine as root or a guest_u account

The following messages are logged to the /var/log/secure file when trying to ssh as the system_u user

Apr 23 23:38:01 localhost sshd[1674]: Accepted password for systemUser from 192.168.56.1 port 55856 ssh2

Apr 23 23:38:01 localhost sshd[1674]: pam_selinux(sshd:session): Security context system_u:system_r:prelink_mask_t:s0-s0:c0.c1023 is not allowed for system_u:system_r:prelink_mask_t:s0-s0:c0.c1023

Apr 23 23:38:01 localhost sshd[1674]: pam_selinux(sshd:session): Unable to get valid context for systemUser

Apr 23 23:38:01 localhost sshd[1674]: pam_unix(sshd:session): session opened for user systemUser by (uid=0)

Apr 23 23:38:01 localhost sshd[1674]: error: PAM: pam_open_session(): Authentication failure

Apr 23 23:38:01 localhost sshd[1674]: error: ssh_selinux_setup_pty: security_compute_relabel: Invalid argument

Apr 23 23:38:01 localhost sshd[1678]: Received disconnect from 192.168.56.1: 11: disconnected by user

Any ideas on how I could modify the policy that creates this behavior?

I am using CentOS 6.8

Best Answer

I hit this same issue and resolved it by restarting sshd. Might work for your scenario ¯\_(ツ)_/¯ ...

Related Topic