大网数据广告活动
服务器运维问答

Again enabled SELINUX and now the user logins wont work in enforcing mode

· 52CE 我爱测

I enabled the SELINUX again on my CentOS 8.2 installation. And now the logins wont work, neither by ssh or direct. To login i have to make the mode to permissive. the secure log shows as below. #login with ssh Sep 14 02:26:57 lcl…

问题原文

原帖链接 · Vipin Jain · CC BY-SA 4.0

I enabled the SELINUX again on my CentOS 8.2 installation. And now the logins wont work, neither by ssh or direct. To login i have to make the mode to permissive. the secure log shows as below.

#login with ssh

Sep 14 02:26:57 lcl sshd[4407]: Accepted password for <MY USERNAME> from <My local ip> port 52410 ssh2
Sep 14 02:26:57 lcl systemd[4412]: pam_unix(systemd-user:session): session opened for user <MY USERNAME> by (uid=0)
Sep 14 02:26:57 lcl sshd[4407]: pam_systemd(sshd:session): Failed to create session: Start job for unit [email omitted] failed with 'failed'
Sep 14 02:26:57 lcl sshd[4407]: pam_unix(sshd:session): session opened for user <MY USERNAME> by (uid=0)
Sep 14 02:26:57 lcl sshd[4421]: fatal: sshd_selinux_copy_context: setcon failed with Permission denied
Sep 14 02:26:57 lcl sshd[4407]: pam_unix(sshd:session): session closed for user <MY USERNAME>

#this is when i tried to login directly without ssh.

Sep 14 02:29:13 lcl systemd[3716]: pam_unix(systemd-user:session): session opened for user <MY USERNAME> by (uid=0)
Sep 14 02:29:13 lcl systemd[3721]: pam_unix(systemd-user:session): session closed for user <MY USERNAME>
Sep 14 02:29:13 lcl login[1225]: pam_systemd(login:session): Failed to create session: Start job for unit [email omitted] failed with 'failed'
Sep 14 02:29:13 lcl login[1225]: pam_unix(login:session): session opened for user <MY USERNAME> by LOGIN(uid=0)
Sep 14 02:29:14 lcl login[1225]: LOGIN ON tty1 BY <MY USERNAME>
Sep 14 02:29:14 lcl login[1225]: pam_unix(login:session): session closed for user <MY USERNAME>

I am not a hardcore server admin please help me fix this issue.

社区高分解答

原帖链接 · zorry · CC BY-SA 4.0

Running with Selinux disabled for a long time can cause files to not be labelled or labelled with Selinux context not matching the installed policy. Also daemons and other processes (including systemd) could run with unexpected contexts.

Shortest way to get it to work, set it to enforcing in /etc/selinux/config, issue the following command:

touch /.autorelabel

Then reboot, you should be able to login now.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-09-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。