FTP服务器安装配置

1.安装:yum install vsftpd -y

2.修改配置文件:cd /etc/vsftpd/

cat > /etc/vsftpd/vsftpd.conf <<EOF
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
vsftpd_log_file=/var/log/vsftpd.log
xferlog_std_format=YES
chroot_local_user=YES
allow_writeable_chroot=YES listen
=YES pam_service_name=vsftpd userlist_enable=YES userlist_deny=NO tcp_wrappers=YES pasv_promiscuous=yes pasv_enable=YES pasv_min_port=50000 pasv_max_port=60000
EOF

# 注释 pam_shells.so
cat /etc/pam.d/vsftpd | grep -v "#" |  grep pam_shells.so  &&  sed -i -re "/\<pam_shells.so\>/s/^/#/"  /etc/pam.d/vsftpd

3.修改防火墙

#开放vsftp端口

-A INPUT -p tcp -m state --state NEW -m tcp --dport 10021 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 50000:60000 -j ACCEPT

4.编写添加用户脚本

cat > /etc/vsftpd/user_add.sh <<'EOF'
#!/bin/bash
user=$1
if [ "$user" = "" ];then
        echo "请输入用户名"
        exit 0
fi

_dir=/data/cdn    #自定义家目录

useradd $user -M -s /sbin/nologin -d $_dir && mkdir -p $_dir

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 $password\e[0m"

EOF

5.运行脚本:sh user_add.sh chenjianwen

6.使用WinSCP测试连接

posted @ 2019-09-05 16:43  chenjianwen  阅读(361)  评论(0编辑  收藏  举报