[CentOS] SELinux 설정 / 해제




참고 : https://www.lesstif.com/pages/viewpage.action?pageId=6979732




SELinux는 Linux의 보안을 강화해 주는 보안 강화 커널이고 zero-day 공격 및 buffer overflow 등 어플리케이션 취약점으로 인한 해킹을 방지해 주는 핵심 구성요소이다.


특정 서비스가 SELinux  때문에 동작하지 않는다면 SELinux를 끄기 보다는 해당 서비스가 SELinux 하에서 잘 동작하도록 설정을 수정하는걸 권장한다.




■ SELinux 동작모드


enforce, permissive, disable 세가지 모드가 있으며 Red Hat Enterprise Linux / CentOS를 설치하면 default 로 enforce mode로 동작하며 ! SELinux의 rule에 어긋나는 operation은 거부된다.


현재 SELinux의 동작 모드는 sestatus 명령으로 확인할 수 있다.


 SELinux 모드 확인

 # sestatus


 SELinux status: enabled

 SELinux mount: /selinux

 Current mode: enforcing

 Mode from config file: enforcing

 Policy version: 24

 Policy from config file: targeted



Permissive mode는 rule에 어긋나는 동작이 있을 경우 audit log를 나믹고 해당 operation은 허용된다.


개발 서버일 경우 특정 daemon 이나 서비스에 문제가 있을 경우 setenforce 0으로 Permissive mode 로 전환하여 문제해결 후 enforce mode로 전환하는걸 추천한다.

 

 # setenforce 0

 # sestatus


 SELinux status: enabled

 SELinux mount: /selinux

 Current mode: permissive

 Mode from config file: enforcing

 Policy version: 24

 Policy from config file: targeted




■ SELinux 해제



 ①

 # vi /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 lo! aded.
 SELINUX=disabled
 # SELINUXTYPE= can take one of three two values:
 #     targeted - Targeted processes are protected,
 #     minimum - Modification of targeted policy. Only selected processes are protected.
 #     mls - Multi Level Security protection.
 SELINUXTYPE=targeted



 ③

 # reboot



※ SELinux 해제한 경우

 · 인터넷에 연결된 리눅스 서버라면 SELinux 해제는 결코 추천하지 않는다.

 · 해제할 경우 다시 활성화 시키려면 재부팅이 필요하며 재부팅시 모든 자원에 대해 보안 레이블을 설정해야 하므로 부팅시간이 매우 오래 걸릴 수 있다.

 · SElinux를 해제후 다시 켤 경우 relabel이 필요하며 이때 잘못된 설정이 있을 경우 부팅이 안되거나 ssh로 원격 접속이 불가능할 수 �! ��으므로 enforcing 모드가 아닌 permissive로 설정후 재부�! �하는것을 권장





by CCL A from http://magic.wickedmiso.com/90

댓글

이 블로그의 인기 게시물

와이파이 이용시 주의사항

카카오톡계정삭제 탈퇴 방법 -아이디 세탁

정보 보안 - 암호