CentOS 8에서 SELinux 해제 방법

CentOS 8에서 SELinux 해제 방법

2022-05-17 last update

6 minutes reading centos security
보안 강화 Linux 또는 SELinux
Linux 커널에 내장된 보안 메커니즘으로, RHEL 기반 릴리스에서 사용됩니다.SELinux를 사용하면 관리자와 사용자가 정책 규칙에 따라 객체에 대한 액세스를 제어하여 시스템에 추가 보안 계층을 추가할 수 있습니다.SELinux 정책 규칙은 프로세스와 사용자가 상호 작용하는 방법과 프로세스와 사용자가 파일과 상호 작용하는 방법을 지정합니다.파일을 여는 프로세스와 같이 객체에 대한 액세스를 명시적으로 허용하는 규칙이 없으면 액세스가 거부됩니다.SELinux는 세 가지 조작 모드가 있는데
  • 강제: SELinux는 SELinux 정책 규칙을 바탕으로 접근할 수 있다.
  • Permissive: SELinux는 강제 모드에서만 실행할 때 거부되는 동작만 기록합니다.이 모드는 새 정책 규칙을 디버깅하고 만드는 데 매우 유용합니다.
  • 해제: SELinux 정책이 로드되지 않고 메시지가 기록되지 않습니다.
  • 기본적으로 SELinux는 CentOS 8에서 활성화 및 강제 모드입니다.SELinux를 강제 모드로 유지하는 것이 좋습니다.그러나 일부 어플리케이션의 기능을 방해하는 경우가 있으므로 라이센스 모드로 설정하거나 완전히 비활성화해야 합니다.이 자습서에서는 CentOS 8에서 SELinux를 비활성화하는 방법에 대해 설명합니다.

    선결 조건

    루트 사용자 또는 권한이 있는 사용자만
    SELinux 모드를 변경할 수 있습니다.

    SELinux 모드 확인

    sestatus 명령을 사용하여 SELinux의 운행 상태와 모드를 검사한다.
    sestatus
    SELinux status:                 enabled
    SELinuxfs mount:                /sys/fs/selinux
    SELinux root directory:         /etc/selinux
    Loaded policy name:             targeted
    Current mode:                   enforcing
    Mode from config file:          enforcing
    Policy MLS status:              enabled
    Policy deny_unknown status:     allowed
    Memory protection checking:     actual (secure)
    Max kernel policy version:      31
    위의 출력은 SELinux가 활성화되고 강제 모드로 설정되었음을 나타낸다.

    SELinux 모드를 허용 모드로 변경

    SELinux가 활성화되면 강제 또는 허용 모드가 될 수 있습니다.다음 명령을 사용하여 대상 모드에서 라이센스 모드로 모드를 일시적으로 변경할 수 있습니다.
    sudo setenforce 0
    . 그러나 이 변경 사항은 현재 실행 중인 세션에만 적용되며 재부팅 동안에는 지속되지 않습니다.SELinux 모드를permissive로 영구적으로 설정하려면
  • 파일을 열고 /etc/selinux/configmod를 SELINUX:/etc/SELinux/config
  • 명령을 실행하여 현재 세션의 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=permissive
    # SELINUXTYPE= can take one of these three values:
    #     targeted - Targeted processes are protected,
    #     minimum - Modification of targeted policy. Only selected processes are protected. 
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted
  • 모드를 허용으로 변경하는 것이 좋습니다.SELinux는 애플리케이션이 정상적으로 실행되는 데 필요한 경우에만 비활성화됩니다.CentOS 8 시스템에서 SELinux를 영구적으로 비활성화하려면 다음 절차를 따르십시오.
  • 파일을 열고 permissive 값을 setenforce 0로 변경합니다./etc/SELinux/config
    sudo shutdown -r now
  • 파일을 저장하고 sudo privileges
    시스템:
    # 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=disabled
    # SELINUXTYPE= can take one of these three values:
    #     targeted - Targeted processes are protected,
    #     minimum - Modification of targeted policy. Only selected processes are protected. 
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted
  • 시스템이 시작되었을 때 /etc/selinux/config 명령을 사용하여 SELinux가 비활성화되었는지 검증한다.
    sudo shutdown -r now
    출력은 다음과 같다.
    sestatus
  • SELinux 해제

    SELinux는 강제 접근 제어(MAC)를 실현함으로써 시스템을 보호하는 메커니즘이다.기본적으로 SELinux는 CentOS 8 시스템에서 활성화되지만 구성 파일을 편집하고 시스템을 재부팅하여 비활성화할 수 있습니다.SELinux의 강력한 기능에 대한 자세한 내용은 reboot를 참조하십시오.
    가이드질문이나 피드백이 있으면 아래에 메시지를 남겨 주십시오.