1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
listen=YES
anonymous_enable=NO
local_enable=YES
chroot_list_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
pam_service_name=vsftpd
guest_enable=YES
guest_username=
ftp
user_config_dir=
/etc/vsftpd/vuser_conf
xferlog_enable=YES
xferlog_std_format=YES
xferlog_file=
/var/log/xferlog
dual_log_enable=YES
#vsftpd_log_file=/var/log/vsftpd.log
port_enable=NO
connect_from_port_20=NO
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40080
pasv_promiscuous=YES
#pasv_address=ec2-52-63-24-226.ap-southeast-2.compute.amazonaws.com
pasv_address=52.63.24.226
|
#安装Berkeley DB工具,很多人找不到db_load的问题就是没有安装这个包
yum install db4 db4-utils
#创建用户密码文本,注意奇行是用户名,偶行是密码
vi /etc/vsftpd/vuser_passwd.txt
test
123456
#生成虚拟用户认证的db文件
db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db
#编辑认证文件,全部注释掉原来语句,再增加以下两句
vi /etc/pam.d/vsftpd
auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd
account required pam_userdb.so db=/etc/vsftpd/vuser_passwd
#创建虚拟用户配置文件
mkdir /etc/vsftpd/vuser_conf/
#文件名等于vuser_passwd.txt里面的账户名,否则下面设置无效
vi /etc/vsftpd/vuser_conf/test
#虚拟用户根目录,根据实际情况修改
local_root=/data/ftp
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
#最新的vsftpd要求对主目录不能有写的权限所以ftp为755,主目录下面的子目录再设置777权限
mkdir /data/ftp
chmod -R 755 /data
chmod -R 777 /data/ftp
#建立限制用户访问目录的空文件
touch /etc/vsftpd/chroot_list
#如果启用vsftpd日志需手动建立日志文件
touch /var/log/xferlog
touch /var/log/vsftpd.log
1
|
<span class=
"line"
style=
"margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"
>打开
/etc/vsftpd/vsftpd
.conf,在末尾添加<
/span
><br><span class=
"line"
style=
"margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"
><
/span
><br><span class=
"line"
style=
"margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"
><span class=
"comment"
style=
"margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(153,153,153);"
>
#开启PASV模式</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">pasv_<span class="built_in" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(249,145,87);">enable</span>=YES</span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"><span class="comment" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(153,153,153);">#最小端口号</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">pasv_min_port=<span class="number" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(249,145,87);">40000</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"><span class="comment" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(153,153,153);">#最大端口号</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">pasv_max_port=<span class="number" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(249,145,87);">40080</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">pasv_promiscuous=YES</span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"><span class="comment" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(153,153,153);">#在防火墙配置内开启40000到40080端口</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">-A INPUT -m state --state NEW -m tcp -p -dport <span class="number" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(249,145,87);">40000</span>:<span class="number" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(249,145,87);">40080</span> -j ACCEPT</span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"><span class="comment" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;color:rgb(153,153,153);">#重启iptabls和vsftpd</span></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">service iptables restart</span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">service vsftpd restart</span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;"></span><br><span class="line" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;vertical-align:baseline;height:20px;">现在可以使用PASV模式连接你的FTP服务器了~</span>
|
如果FTP客户端软件,命令行下可以连接,但资源管理器无法打开FTP,如下图。需要在配置文件中增加一条命令,增加之后即可解决问题:
1
|
pasv_address=
52.63
.
24.226
|
本文转自 安安安安森 51CTO博客,原文链接:http://blog.51cto.com/smallc/1836668,如需转载请自行联系原作者