To turn on SELinux on a Red Hat or CentOS Linux system over a remote SSH session, follow these steps:
Connect to the system via SSH as the root user.
Edit the /etc/selinux/config
file by running the following command:
nano /etc/selinux/config
SELINUX=disabled
SELINUX=enforcing
Save the file and exit the editor.
Run the following command to apply the changes:
setenforce enforcing
reboot
SELinux will now be enabled on the system.
Note: If you want to set SELinux to permissive mode instead of enforcing mode, change the
SELINUX
line toSELINUX=permissive
and run thesetenforce permissive
command. In permissive mode, SELinux will log actions that would be denied in enforcing mode, but it will not actually enforce the rules.