Tag: SELinux

  • SELinux allow non default SSH port

    SELinux allow non default SSH port

    By default, SELinux only allows running SSH service on default port 22. For security, it is better to change the SSH port to a non-standard port. On Systems running SELinux, sshd service will fail to start if you change the SSH port.

    To allow a custom SSH port, run

    semanage port -a -t ssh_port_t -p tcp SSH_PORT_HERE
    

    For example, to alow sshd service run on port 3333, use

    semanage port -a -t ssh_port_t -p tcp 3333
    

    Back to SELinux

  • Disable SELinux on CentOS/RHEL

    To disable SELinux

    Method 1

    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    setenforce 0
    

    Method 2

    edit file

    vi /etc/selinux/config
    

    Find

    SELINUX=enforcing
    

    Replace with

    SELINUX=disabled
    

    Reboot the server with

    reboot
    

    You can disable selinux for current session by running command

    setenforce 0
    

    See SELinux

  • SELinux

    To disable SELinux, edit

    sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

    Now you need to reboot. If you don’t want to reboot, disable it for current session with

    setenforce 0

    If you use SELinux, you may need to configure it for each applications.

    For web server

    setsebool httpd_can_network_connect true
    setsebool -P httpd_can_network_connect_db 1
    setsebool -P memcached_connect_any 1

    CURL ERROR 7 could not establish a secure connection to WordPress.org
    SELinux allow non default SSH port