AllTechWiki



A Place for All Technical Stuff Linux Cloud etc

Not able to SSH to Linux ssh_selinux_change_context: setcon system_u:system_r:sshd_net_t:s0 failed with Permission denied [preauth]

Not able to SSH to CentOS 7.x /RHEL 7.x and showing following errors in /var/log/secure messages.



Nov 19 07:30:54 cent7-1 sshd[1944]: Accepted password for naveen from 192.168.1.8 port 53376 ssh2

Nov 19 07:30:54 cent7-1 sshd[1944]: pam_systemd(sshd:session): Failed to create session: Access denied

Nov 19 07:30:54 cent7-1 sshd[1944]: pam_unix(sshd:session): session opened for user naveen by (uid=0)

Nov 19 07:30:55 cent7-1 sshd[1976]: sshd_selinux_copy_context: setcon failed with Permission denied

Nov 19 07:30:55 cent7-1 sshd[1976]: Received disconnect from 192.168.1.8 port 53376:11: disconnected by user

Nov 19 07:30:55 cent7-1 sshd[1976]: Disconnected from 192.168.1.8 port 53376

Nov 19 07:30:55 cent7-1 sshd[1944]: pam_unix(sshd:session): session closed for user naveen

Nov 19 07:31:14 cent7-1 sshd[2059]: ssh_selinux_change_context: setcon system_u:system_r:sshd_net_t:s0 from system_u:system_r:kernel_t:s0 failed with Permission denied [preauth]

Nov 19 07:31:26 cent7-1 sshd[2100]: ssh_selinux_change_context: setcon system_u:system_r:sshd_net_t:s0 from system_u:system_r:kernel_t:s0 failed with Permission denied [preauth]

Nov 19 07:31:35 cent7-1 sshd[2100]: Accepted password for naveen from 192.168.1.10 port 50668 ssh2

Nov 19 07:31:36 cent7-1 sshd[2100]: pam_systemd(sshd:session): Failed to create session: Access denied

Nov 19 07:31:36 cent7-1 sshd[2100]: pam_unix(sshd:session): session opened for user naveen by (uid=0)

Nov 19 07:31:36 cent7-1 sshd[2138]: sshd_selinux_copy_context: setcon failed with Permission denied

Nov 19 07:31:36 cent7-1 sshd[2100]: pam_unix(sshd:session): session closed for user naveen

Nov 19 07:31:39 cent7-1 sshd[2156]: ssh_selinux_change_context: setcon system_u:system_r:sshd_net_t:s0 from system_u:system_r:kernel_t:s0 failed with Permission denied [preauth]

Nov 19 07:31:49 cent7-1 sshd[2156]: Accepted password for root from 192.168.1.10 port 50671 ssh2

Nov 19 07:31:49 cent7-1 sshd[2156]: pam_systemd(sshd:session): Failed to create session: Access denied

Nov 19 07:31:49 cent7-1 sshd[2156]: pam_unix(sshd:session): session opened for user root by (uid=0)

Nov 19 07:31:49 cent7-1 sshd[2156]: sshd_selinux_copy_context: setcon failed with Permission denied

Nov 19 07:31:50 cent7-1 sshd[2213]: sshd_selinux_copy_context: setcon failed with Permission denied

Nov 19 07:31:50 cent7-1 sshd[2156]: pam_unix(sshd:session): session closed for user root

Nov 19 07:31:52 cent7-1 sshd[2228]: ssh_selinux_change_context: setcon system_u:system_r:sshd_net_t:s0 from system_u:system_r:kernel_t:s0 failed with Permission denied [preauth]

Nov 19 07:32:00 cent7-1 sshd[2228]: Accepted password for kumar from 192.168.1.10 port 50673 ssh2

Nov 19 07:32:00 cent7-1 sshd[2228]: pam_systemd(sshd:session): Failed to create session: Access denied

Nov 19 07:32:00 cent7-1 sshd[2228]: pam_unix(sshd:session): session opened for user kumar by (uid=0)

Nov 19 07:32:00 cent7-1 sshd[2279]: sshd_selinux_copy_context: setcon failed with Permission denied

Nov 19 07:32:00 cent7-1 sshd[2228]: pam_unix(sshd:session): session closed for user kumar

Nov 19 07:32:14 cent7-1 sshd[2059]: Connection reset by 192.168.1.8 port 53377 [preauth]

Nov 19 07:34:35 cent7-1 sshd[2781]: ssh_selinux_change_context: setcon system_u:system_r:sshd_net_t:s0 from system_u:system_r:kernel_t:s0 failed with Permission denied [preauth]

Nov 19 07:34:42 cent7-1 sshd[2781]: Accepted password for naveen from 192.168.1.14 port 44776 ssh2

Nov 19 07:34:42 cent7-1 sshd[2781]: pam_systemd(sshd:session): Failed to create session: Access denied

Nov 19 07:34:42 cent7-1 sshd[2781]: pam_unix(sshd:session): session opened for user naveen by (uid=0)

Nov 19 07:34:42 cent7-1 sshd[2812]: sshd_selinux_copy_context: setcon failed with Permission denied

Nov 19 07:34:42 cent7-1 sshd[2812]: Received disconnect from 192.168.1.14 port 44776:11: disconnected by user

Nov 19 07:34:42 cent7-1 sshd[2812]: Disconnected from 192.168.1.14 port 44776

Nov 19 07:34:42 cent7-1 sshd[2781]: pam_unix(sshd:session): session closed for user naveen

I tried to chroot the problematic VM from another VM-cent8-1.

While checking the sestatus it was showing as disabled in chroot environment but actually it was set to enforcing 

[root@cent8-1 log]# sestatus

SELinux status:                 disabled

[root@cent8-1 log]# cat /etc/sysconfig/selinux


# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=enforcing

# SELINUXTYPE= can take one of three values:

#     targeted - Targeted processes are protected,

#     minimum - Modification of targeted policy. Only selected processes are protected.

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

Now change the SELINUX to disabled state.

[root@cent8-1 log]# vi /etc/sysconfig/selinux


Change the SELINUX to disabled

>> Swap the OS disk and tried to login.
>> Post that I can able to SSH the cent7-1 and able to see following logs.

Nov 19 07:53:10 cent7-1 login: LOGIN ON tty1 BY naveen
Nov 19 07:53:19 cent7-1 sshd[1384]: Accepted password for naveen from 192.168.1.10 port 50755 ssh2
Nov 19 07:53:19 cent7-1 sshd[1384]: pam_unix(sshd:session): session opened for user naveen by (uid=0)
Nov 19 07:53:26 cent7-1 sudo:  naveen : TTY=pts/0 ; PWD=/home/naveen ; USER=root ; COMMAND=/bin/su
Nov 19 07:53:26 cent7-1 sudo: pam_unix(sudo:session): session opened for user root by naveen(uid=0)
Nov 19 07:53:26 cent7-1 su: pam_unix(su:session): session opened for user root by naveen(uid=0)
Nov 19 07:53:40 cent7-1 su: pam_unix(su:session): session closed for user root
Nov 19 07:53:40 cent7-1 sudo: pam_unix(sudo:session): session closed for user root
Nov 19 07:53:52 cent7-1 sudo:  naveen : TTY=tty1 ; PWD=/home/naveen ; USER=root ; COMMAND=/bin/su
Nov 19 07:53:52 cent7-1 sudo: pam_unix(sudo:session): session opened for user root by naveen(uid=0)
Nov 19 07:53:52 cent7-1 su: pam_unix(su:session): session opened for user root by naveen(uid=0)
Nov 19 07:53:56 cent7-1 sudo:  naveen : TTY=pts/0 ; PWD=/home/naveen ; USER=root ; COMMAND=/bin/su
Nov 19 07:53:56 cent7-1 sudo: pam_unix(sudo:session): session opened for user root by naveen(uid=0)
Nov 19 07:53:56 cent7-1 su: pam_unix(su:session): session opened for user root by naveen(uid=0)

[root@cent7-1 naveen]# uname -a
Linux cent7-1 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
[root@cent7-1 naveen]#

[root@cent7-1 naveen]# uptime
 08:02:40 up 9 min,  2 users,  load average: 0.01, 0.09, 0.10
[root@cent7-1 naveen]#




Post a Comment

Previous Post Next Post

Basic Useful Links