Friday, June 14, 2013

Enable & Disable SELinux

Enable & Disable SELinux on CentOS :

Disable SELinux :
Run on terminal
# echo 0 > /selinux/enforce
or
# setenforce 0
No need to reboot using above commands but when system will reboot SELinux will be enabled again.

Enable SELinux :
# echo 1 > /selinux/enforce
or
# setenforce 1
No need to reboot using above commands.

Permanent Solution (Disable SELinux ):
Open file /etc/selinux/config
change SELINUX=enforcing to SELINUX=permissive 
or 
SELINUX=enforcing to SELINUX=disabled
Reboot the system.
It will disable the SELinux permanently.

Check status of SELinux
# getenforce
Output is :
Disabled

Another command :
# sestatus
Output is :
SELinux status:                 disabled

Could not chdir to home directory /home/user: Permission denied -bash: /home/user/.bash_profile: Permission denied

Error : Could not chdir to home directory /home/user: Permission denied -bash: /home/user/.bash_profile: Permission denied

The error opens the bash prompt instead of user prompt when user tries to login using ssh.
Set the home directory permission to 775
$ chmod 775 /home/

It sets the permission of directory /home 775. Do not give recursive permission, it means the permission of directories inside /home (sub-dirs of /home) should not be 775. They should be 700.

/home should be 775 & directories inside /home should be 700.

If you think it will increase the number of hazardous attempts, then try second solution. Although it is about security too. You should disable the SELinux.

SSH : agent admitted failure to sign using the key

Error : Agent admitted failure to sign using the key :

Solution :

Run following command on the client
# ssh-add