1.安装:yum install vsftpd -y
2.修改配置文件:cd /etc/vsftpd/
cat vsftpd.conf | grep -Ev '^$|^#' listen_port=10021 anonymous_enable=NO local_enable=YES write_enable=YES local_umask=002 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_file=/var/log/vsftpd.log xferlog_std_format=YES chroot_local_user=YES listen=YES pam_service_name=vsftpd userlist_enable=YES userlist_deny=NO tcp_wrappers=YES pasv_promiscuous=yes pasv_enable=YES pasv_address=本机地址 pasv_min_port=50000 pasv_max_port=60000
3.修改防火墙
#开放vsftp端口 -A RH-Firewall-1-INPUT -p tcp --dport 10021 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp --dport 50000:60000 -j ACCEPT
4.编写添加用户脚本
cat user_add.sh #!/bin/bash user=$1 if [ "$user" = "" ];then echo "请输入用户名" exit 0 fi _dir=/data/www #自定义家目录 [ ! -d $_dir ] && mkdir -p $_dir [ `id oss_ftp | wc -l` -eq 0 ] && useradd -s /sbin/nologin -d $_dir oss_ftp useradd -s /sbin/nologin -d $_dir -g oss_ftp $user password="${user}111111" echo $password | passwd $user --stdin echo "$user $password" >> passwd echo "$user" >> user_list service vsftpd restart echo -e "# [ $(date '+%F %T') ] #e[33m 用户名密码: $user $passworde[0m"
5.运行脚本:sh user_add.sh chenjianwen
6.使用WinSCP测试连接