检查selinux 是开启的状态:
$ getenforce
直接修改selinux状态:
$ setenforce 1 #设置SELinux 成为enforcing模式$ setenforce 0 #设置SELinux 成为permissive模式
如果要彻底禁用SELinux 需要在/etc/sysconfig/selinux中设置参数SELINUX=disabled
$ 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 loaded.#SELINUX=enforcingSELINUX=disabled ####### 修改这里即可# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted
常见问题:使用ssk-keygen –rsa配置无密码通道成功后(目录权限700,authorized_keys权限600),发现无论如何都不能正常登陆。如果检查发现后面有—-. 点结尾,那么就有可能是selinux是开着的,关掉应该就可以了.
$ ls -la .ssh/total 24drwx------. 2 www www 4096 Oct 15 05:14 .drwxr-xr-x. 7 www www 4096 Oct 13 01:16 ..-rw-------. 1 www www 829 Oct 15 05:32 authorized_keys-rw-------. 1 www www 1675 Sep 30 06:07 id_rsa-rw-r--r--. 1 www www 401 Sep 30 06:07 id_rsa.pub-rw-r--r--. 1 www www 2042 Oct 15 05:30 known_hosts
原文地址:如何开关selinux呢?, 感谢原作者分享。 只要有信心,人永远不会挫败