Self-Improvement

SELinux 기초 명령어 및 실습 본문

리눅스/보안

SELinux 기초 명령어 및 실습

JoGeun 2018. 10. 23. 22:27

*정의
SELinux의 기본 목적은 손상된 시스템 서비스로 부터 사용자 데이터를 보호하는 것이다.
SELinux는 프로세스가 파일, 디렉토리, 포트에 액세스 할 수 있는지 결정하는 보안 규칙의 집합이다.

*모드
1.Disable
   : SELinux가 꺼져 있고 액세스 제어의 기본 방식인 DAC가 사용되며 고급 보안이 필요 하지 않는 환경에서 사용된다.

2.Permissive
   : SELinux가 켜져 있고 다만 보안 정책 규칙은 강제되지 않는다. 보안 정책에 위반이 되어도 액세스는 허용되지만 메시지 /var/log/audit에 로그파일로 기록을 남긴다.

3.Enforce
   : SELinux가 켜져 있고 모든 보안 정책 규칙이 강제 된다.

//현재 SELinux 모드 확인
#sestatus (=getenfoce) 


#cat /etc/sysconfig/selinux 


//enforcing < - > permissive 전환 
#setenforce [0/1] 
#sestatus 


*SELinux 관련 패키지 설치 
# yum -y install policycoreutils \ 
selinux-policy \ 
selinux-policy-targeted \ 
libselinux \ 
libselinux-utils \ 
libselinux-python  

# yum -y install selinux-policy-mls \ 
setroubleshoot \ 
setroubleshoot-server \ 
setools-gui \ 
setools-console \ 
mcstrans \ 
policycoretuils-python \ 
policycoreutils-gui  

*audit, rsyslog 서비스 활성화 
 - auditd 데몬이 실행중이면 /var/log/audit/audit.log에 자세한 감사 로그가 쌓이게 된다


*SELinux 기본 명령어 실습 (semanage boolean, getsebool, setsebool)
#semanage boolean -l | grep ftp 


#getsebool allow_ftpd_full_access 


#setsebool allow_ftpd_full_access on 
#getsebool allow_ftpd_full_access


#semanage boolean -l | grep allow_ftp 


*파일의 SELinux Context 변경하는 명령어 실습 (chcon, restorecon, semanage fcontext)
#touch file1
#ls -Z 


#chcon -t samba_share_t file1 (임시적으로 변경 <-> semanage fcontext -a -t samba_share_t file1) 
#ls -Z 


#restorecon -v file1 


#ls-Z 


//file에 대한 contexts 설정된 파일 확인 
#cat /etc/selinux/targeted/contexts/files/file_contexts | more  


*기타 명령어 
#avcstat 
#seinfo 
#sesearch 

*GUI 
#system-config-selinux

'리눅스 > 보안' 카테고리의 다른 글

File ACL, 디렉토리의 Default ACL  (0) 2018.10.24
sudo  (0) 2018.10.23
TCP_Wrappers 서비스  (0) 2018.10.23
방화벽(iptables)2 간단실습  (0) 2018.10.23
방화벽(iptables)  (0) 2018.10.23