SELinux在enforcing模式下配置vsftp,运行指定用户访问

安装vsftp这里就略过了,打开配置文件
[root@localhost yjj]# vim /etc/vsftpd/vsftpd.conf
 12 anonymous_enable=NO    //关闭匿名登录
119 userlist_deny=YES
120 userlist_file=/etc/vsftpd/user_list
更改上边对应的行
[root@localhost yjj]# cd /etc/vsftpd/
[root@localhost vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd.conf.bak  vsftpd_conf_migrate.sh
在user_list中添加yangjj用户,不允许yangjj访问
[root@localhost vsftpd]# vim user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
yangjj
重启vsftp
[root@localhost vsftpd]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
此时访问ftp,你会发现无法访问,这是由于SELinux引起的。
[root@localhost yjj]# setsebool -P ftp_home_dir=on
[root@localhost yjj]# setsebool -P ftpd_connect_db=on
如上设置之后,除了上面user_list中列到的用户,其他用户都可以正常访问ftp,进入之后,ftp显示的是他主目录中的内容

你可能感兴趣的:(linux,vsftp,职场,selinux,休闲)