标签:password roo chroot star username 用户名 login wrapper rap
#!/bin/bash
#author:vaedit
#date:2017/11/14
read -p "请输出用户名" name
read -p "请输入密码" password
echo -e ‘\033[32;40;1m开始安装\033[0m‘
yum install vsftpd db4 db4-utils -y
useradd -s /sbin/nologin ftpuser
mv /etc/vsftpd/vsftpd.conf{,.bak}
#创建配置文件
cat>/etc/vsftpd/vsftpd.conf <<EOF
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
vsftpd_log_file=/var/log/vsftpd.log
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=ftpuser
user_config_dir=/etc/vsftpd/vuser_conf
virtual_use_local_privs=YES
EOF
touch /etc/vsftpd/chroot_list
#创建账户密码文件
cat>/etc/vsftpd/vuser_passwd.txt<<EOF
$name
$password
EOF
db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db
cat>/etc/pam.d/vsftpd<<EOF
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd
EOF
#创建虚拟用户配置文件
mkdir /etc/vsftpd/vuser_conf -p
cat>/etc/vsftpd/vuser_conf/$name<<EOF
local_root=/data/backup
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
EOF
mkdir /data/backup -p
chown ftpuser.ftpuser /data/backup -R
setenforce 0
service vsftpd start
ps -ef|grep vsftpd
netstat -ntulp|grep ":21"
适当修改即可使用哦
标签:password roo chroot star username 用户名 login wrapper rap
原文地址:https://blog.51cto.com/vaedit/2479838