标签:stop mct systemctl images install useradd water 库文件 虚拟用户
vsftpd 虚拟用户配置[root@linfan ~]#systemctl stop firewalld
[root@linfan ~]#systemctl disable firewalld
[root@linfan ~]# sed -i"s/^SELINUX\=enforcing/SELINUX\=disabled/g" /etc/selinux/config
[root@linfan ~]#setenforce 0
[root@linfan ~]# cd /etc/yum.repos.d/
[root@linfan yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@linfan yum.repos.d]# yum clean all
[root@linfan yum.repos.d]# yum -y install epel-release
[root@linfan yum.repos.d]# yum -y install vsftpd
[root@linfan yum.repos.d]# cd
[root@linfan ~]# cat >> /etc/vsftpd/vu.list <<EOF
> lin
> 123
> fan
> 456
> EOF
[root@linfan ~]# cat /etc/vsftpd/vu.list
lin
123
fan
456
[root@linfan ~]# yum -y install db4*
[root@linfan ~]# db_load -T -t hash -f /etc/vsftpd/vu.list /etc/vsftpd/vu.db
// -T 表示转换 -t表示加密方式hash的算法加密
[root@linfan ~]# db_load -T -t hash -f /etc/vsftpd/vu.list /etc/vsftpd/vu.db
[root@linfan ~]# chmod 600 /etc/vsftpd/vu.*
[root@linfan ~]# ll /etc/vsftpd/vu.*
-rw-------. 1 root root 12288 Aug 7 18:56 /etc/vsftpd/vu.db
-rw-------. 1 root root 16 Aug 7 18:54 /etc/vsftpd/vu.list
[root@linfan ~]# useradd -d /var/ftproot -s /sbin/nologin vftp
[root@linfan ~]# chmod 755 /var/ftproot/
[root@linfan ~]# ll -d /var/ftproot/
drwxr-xr-x. 3 vftp vftp 78 Aug 7 18:57 /var/ftproot/
[root@linfan ~]# cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
[root@linfan ~]# vim /etc/pam.d/vsftpd
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd/vu
account required pam_userdb.so db=/etc/vsftpd/vu
[root@linfan ~]# cat >> /etc/vsftpd/vsftpd.conf <<EOF
> guest_enable=YES
> guest_username=vftp
> user_config_dir=/etc/vsftpd/vusers_dir
> allow_writeable_chroot=YES
> EOF
[root@linfan ~]# mkdir /etc/vsftpd/vusers_dir
[root@linfan ~]# ll /etc/vsftpd/
total 32
-rw-------. 1 root root 125 Aug 3 2017 ftpusers
-rw-------. 1 root root 361 Aug 3 2017 user_list
-rw-------. 1 root root 5133 Aug 7 18:59 vsftpd.conf
-rwxr--r--. 1 root root 338 Aug 3 2017 vsftpd_conf_migrate.sh
-rw-------. 1 root root 12288 Aug 7 18:56 vu.db
-rw-------. 1 root root 16 Aug 7 18:54 vu.list
drwxr-xr-x. 2 root root 6 Aug 7 18:59 vusers_dir
[root@linfan ~]# cat >> /etc/vsftpd/vusers_dir/lin <<EOF
> anon_upload_enable=YES
> anon_mkdir_write_enable=YES
> EOF
[root@linfan ~]# touch /etc/vsftpd/vusers_dir/fan
[root@linfan ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 32 :::21 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
[root@linfan ftproot]# ls
4 helleo hello
lin用户有下载和创建文件的权限;
fan 用户只可以下载文件,没有创建文件的权限
标签:stop mct systemctl images install useradd water 库文件 虚拟用户
原文地址:http://blog.51cto.com/13858192/2155897