help:selinux
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
help:selinux [2020/07/19 12:03] – old revision restored (2016/07/11 11:39) 173.212.242.224 | help:selinux [2020/07/19 20:09] (current) – old revision restored (2016/07/11 11:59) 192.99.4.140 | ||
---|---|---|---|
Line 5: | Line 5: | ||
SELinux enforces the idea that programs should be limited in what files they can access and what actions they can take. | SELinux enforces the idea that programs should be limited in what files they can access and what actions they can take. | ||
- | SELinux is a kernel security extension, which can be used to guard against misconfigured or compromised programs. | + | SELinux is a kernel security extension, which can be used to guard against misconfigured or compromised programs. |
+ | |||
+ | SELinux can be any one of the following state: | ||
* enforcing – SELinux security policy is enforced. | * enforcing – SELinux security policy is enforced. | ||
Line 11: | Line 13: | ||
* disabled – SELinux is fully disabled. | * disabled – SELinux is fully disabled. | ||
+ | [[SELinux: | ||
[[SELinux: | [[SELinux: | ||
[[SELinux: | [[SELinux: | ||
+ | |||
+ | [[SELinux: | ||
[[SELinux: | [[SELinux: | ||
- | [[SELinux:Install SELinux|Install SELinux]] | + | [[SELinux:Confine users|Confine users]] |
- | [[SELinux:Run SELinux in permissive mode|Run SELinux in permissive mode]] | + | [[SELinux:Find Unprotected Services|Find Unprotected Services]] |
+ | [[SELinux: | ||
+ | [[SELinux: | ||
+ | [[SELinux: | ||
- | ===== Set SELINUX to enforcing | + | [[SELinux: |
- | Edit / | + | [[SELinux:Temporarily Switch Off SELinux Enforcement|Temporarily Switch Off SELinux Enforcement]] |
- | <code bash> | + | [[SELinux: |
- | vi / | + | |
- | </ | + | |
- | Update the configuration file as follows: | + | [[SELinux:Troubleshooting SELinux Policy Errors|Troubleshooting SELinux Policy Errors]] |
- | <file bash / | + | [[SELinux: |
- | SELINUX=enforcing | + | |
- | SELINUXTYPE=targeted | + | |
- | </ | + | |
- | ===== Understanding SELinux Configuration | + | [[SELinux: |
- | * SELINUX=enforcing : Enforcing is the default mode which will enable and enforce the SELinux security policy on the Linux. | ||
- | * SELINUXTYPE=targeted : Only targeted network daemons (such as DNS, Apache and others) are protected. | ||
- | Save and close the file. Make sure SELinux is not disabled using Grub boot loader. | ||
- | <code bash> | ||
- | egrep -i ' | ||
- | </ | ||
- | If you found lines with selinux=0 or enforcing=0, | ||
- | Reboot the server: | ||
- | <code bash> | ||
- | reboot | ||
- | </ | ||
- | |||
- | |||
- | ===== Make Sure SELinux is Properly Enabled ===== | ||
- | |||
- | Type the following command: | ||
- | |||
- | |||
- | <code bash> | ||
- | sestatus | ||
- | </ | ||
- | |||
- | Sample outputs: | ||
- | |||
- | < | ||
- | SELinux status: | ||
- | SELinuxfs mount: | ||
- | Current mode: | ||
- | Mode from config file: enforcing | ||
- | Policy version: | ||
- | Policy from config file: targeted | ||
- | </ | ||
- | |||
- | |||
- | ===== Print Full List Of Allowed Network Ports ===== | ||
- | |||
- | Type the following commands: | ||
- | |||
- | <code bash> | ||
- | semanage port -l | ||
- | semanage port -l | less | ||
- | #### look for port 80 #### | ||
- | semanage port -l | grep -w 80 | ||
- | </ | ||
- | |||
- | |||
- | ===== Allow Lighttpd / Apache / Nginx At Port 8181 ===== | ||
- | |||
- | By default SELinux will block access to many ports including 8181. You need to allow access to a port # 8181 so that it can bind and listen for incoming requests on non privileged ports. | ||
- | |||
- | <code bash> | ||
- | semanage port -a -t http_port_t -p tcp 8181 | ||
- | </ | ||
- | |||
- | |||
- | ===== Find Unprotected Services ===== | ||
- | |||
- | Type the following command: | ||
- | |||
- | <code bash> | ||
- | ps -eZ | egrep " | ||
- | </ | ||
- | You should not see any output on fully configured SELinux systems. | ||
Line 131: | Line 71: | ||
</ | </ | ||
- | |||
- | ===== Troubleshooting SELinux Policy Errors ===== | ||
- | |||
- | SELinux is pretty complicated kernel software. | ||
- | |||
- | * ps -Z -p PID | ||
- | * ls -Z fileName | ||
- | * ausearch | ||
- | * restorecon | ||
- | * semodule | ||
- | * audit2allow | ||
- | * Log files: / | ||
- | |||
- | Recommended readings: | ||
- | |||
- | * Introduction to the Red Hat SELinux Guide [https:// | ||
Line 165: | Line 89: | ||
- | ===== Temporarily Switch Off SELinux Enforcement ===== | ||
- | Type the following command as root user: | ||
- | <code bash> | ||
- | echo 0 >/ | ||
- | </ | ||
- | Type the following command to see current status, enter: | ||
- | <code bash> | ||
- | sestatus | ||
- | </ | ||
- | Sample outputs: | ||
- | |||
- | < | ||
- | SELinux status: | ||
- | SELinuxfs mount: | ||
- | Current mode: | ||
- | Mode from config file: enforcing | ||
- | Policy version: | ||
- | Policy from config file: targeted | ||
- | </ | ||
- | |||
- | |||
- | ===== Temporarily switch on SELinux enforcement ===== | ||
- | |||
- | Type the following command as root user: | ||
- | |||
- | <code bash> | ||
- | echo 1 >/ | ||
- | </ | ||
- | |||
- | Type the following command to see current status, enter: | ||
- | |||
- | <code bash> | ||
- | sestatus | ||
- | </ | ||
- | |||
- | Sample outputs: | ||
- | |||
- | <code bash> | ||
- | SELinux status: | ||
- | SELinuxfs mount: | ||
- | Current mode: | ||
- | Mode from config file: enforcing | ||
- | Policy version: | ||
- | Policy from config file: targeted | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== Turn off SELinux ===== | ||
- | |||
- | Type the following command: | ||
- | |||
- | <code bash> | ||
- | echo 0 >/ | ||
- | </ | ||
- | |||
- | You can also use the setenforce command to effectively disable it, enter: | ||
- | |||
- | <code bash> | ||
- | setenforce Permissive | ||
- | </ | ||
- | |||
- | OR | ||
- | |||
- | <code bash> | ||
- | setenforce 0 | ||
- | </ | ||
- | |||
- | The above commands will switch off SELinux enforcement temporarily until the machine is rebooted. | ||
- | |||
- | <code bash> | ||
- | vi / | ||
- | </ | ||
- | |||
- | And set / update it as follows: | ||
- | |||
- | <file bash / | ||
- | SELINUX=disabled | ||
- | </ | ||
- | |||
- | Save and close the file. The above will only work in CentOS, Fedora and RedHat Enterprise Linux systems. | ||
- | |||
- | <file / | ||
- | title Red Hat Enterprise Linux Server (2.6.18-194.26.1.el5) | ||
- | root (hd0,0) | ||
- | kernel / | ||
- | initrd / | ||
- | </ | ||
- | |||
- | Finally, reboot the system: | ||
- | |||
- | <code bash> | ||
- | reboot | ||
- | </ | ||
- | |||
- | |||
- | |||
- | [[SELinux: | ||
help/selinux.1595160210.txt.gz · Last modified: 2020/07/19 12:03 by 173.212.242.224