# cat /etc/pam.d/login --以这个控制系统登录的配置文件为例,每一行就是一个控制方式
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include system-auth
-session optional pam_ck_connector.so
# vim /etc/selinux/config
# 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 - SELinux is fully disabled. --直接关闭selinux
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
--selinux类型,也就是策略policy现在分为2大类。
1,targeted 红帽开发的,主要是对网络服务进行保护
2,strict NSA开发,对整个系统进行多级别保护
2,客户端登录,使用abc用户,密码123登录不上去
# ftp 10.1.1.6
Connected to 10.1.1.6 (10.1.1.6).
220 (vsFTPd 2.2.2)
Name (10.1.1.6:root): abc
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/abc
Login failed.
3,通过开关setenforce 0发现是selinux禁止了
4,通过ftp服务器上执行下面命令
# sealert
# sealert -a /var/log/audit/audit.log --使用这两种方法都可以得到下面的一段提示
If you want to allow ftp to read and write files in the user home directories
Then you must tell SELinux about this by enabling the 'ftp_home_dir' boolean.You can read 'user_selinux' man page for more details.
Do
setsebool -P ftp_home_dir 1
5,解决方法:
在服务器上setsebool -P ftp_home_dir=1
6,客户端再次测试,可以登录,也可以正常下载
排错实例2
1,在服务器端安装samba,并启动
# yum install samba-* -y
# /etc/init.d/smb restart
# smbpasswd -a abc
New SMB password:
Retype new SMB password:
Added user abc.
以前要转换用户身份做一个事情的方法有:
suid可以在执行一个命令转换身份
su - 用户 -c "命令"
sudo
sudo, sudoedit - execute a command as another user
管理员有root的密码,在管理时也不用root用户,而用一个普通用户(为了安全,防止用root做误操作)。但是普通用户并没有所有的权限,所以可以在root对这个普通用户授权,让它能够做root能做的事情).
$ sudo touch /root/abc --命令前加sudo,第一次使用sudo,会有下面的一段话
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for abc: --输入的是abc的密码,而不是root的密码,就可以成功创建
$ sudo ls -l /root/abc --再次用sudo就不需要输入密码了,也可以看到其实还是用的root的身份
-rw-r--r-- 1 root root 0 Nov 7 09:59 /root/abc
例2:授于普通用户abc部分权限
# vim /etc/sudoer
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
root ALL=(ALL) ALL
abc ALL=SERVICES
测试:abc用户可以使用service,chkconfig对服务进行操作,但其它比如touch /root/abc就不可以再做了