0

I'm seeing a strange warning when I log onto my Ubuntu box from my Mac, "Unable to get valid context for <user>". I don't remember when this started, or what could've possibly changed to cause this. I haven't experienced any adverse effects as of yet, I'm just unsure why this message appears now.

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-104-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.


Unable to get valid context for meanwhileinhell
Last login: Tue Dec 19 10:31:44 2017 from 192.168.2.1


/var/log/auth.log

sshd[6147]: Accepted publickey for meanwhileinhell from 192.168.2.1 port 57194 ssh2: RSA SHA256:<key>
sshd[6147]: pam_unix(sshd:session): session opened for user meanwhileinhell by (uid=0)
systemd-logind[780]: New session 6 of user meanwhileinhell.
sshd[6147]: pam_selinux(sshd:session): Unable to get valid context for meanwhileinhell
sshd[6177]: error: ssh_selinux_getctxbyname: Failed to get default SELinux security context for meanwhileinhell
sshd[6147]: error: ssh_selinux_getctxbyname: Failed to get default SELinux security context for meanwhileinhell
sshd[6147]: error: ssh_selinux_setup_pty: security_compute_relabel: Invalid argument


$ sestatus -v

SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             ubuntu
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      30

Process contexts:
Current context:                system_u:system_r:kernel_t:s0
Init context:                   system_u:system_r:kernel_t:s0

File contexts:
Controlling terminal:           system_u:object_r:devpts_t:s0
/etc/passwd                     system_u:object_r:file_t:s0
/etc/shadow                     system_u:object_r:file_t:s0
/bin/bash                       system_u:object_r:file_t:s0
/bin/login                      system_u:object_r:file_t:s0
/bin/sh                         system_u:object_r:file_t:s0 -> 
system_u:object_r:file_t:s0
/sbin/agetty                    system_u:object_r:file_t:s0
/sbin/init                      system_u:object_r:file_t:s0 -> 
system_u:object_r:file_t:s0
/usr/sbin/sshd                  system_u:object_r:file_t:s0

I know very little about SELinux so am hesitant to go ahead and just run unknown commands, but I'd be very grateful if someone could help me understand what this means. I found this SO question Linux console: "Unable to get valid context for..." but it doesn't provide anything useful.

$ semanage login -l
ValueError: SELinux policy is not managed or store cannot be accessed.
0
$ semanage login -l

This fails because you need to do it as root. It works when I use "sudo". I don't know if that puts you any closer to the answer; I stumbled across your question while also trying to find out how to resolve this!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.