ftp 文件传输协议 跨平台 上传下载文件

ftp  文件传输协议 跨平台 上传下载文件

vsftpd 工具:非常安全的文件传输协议;默认的命令端口21号,数据端口20(默认在主动模式下),vsftpd后台进程,ftp用户来管理。

# rpm -qi vsftpd-2.0.5-16.el5

Summary    : vsftpd – Very Secure Ftp Daemon

Description :

vsftpd is a Very Secure FTP daemon. It was written completely from

scratch.

主动模式:默认情况下,ftp服务是开放了21端口,用来接受控制命令,服务器用20端口去发送数据(连接客户端大于1024的随机端口)

被动模式:ftp服务也是开放21端口,用来接受命令控制,进行数据传输时,客户端会告知服务端打开一个大于1024的端口,然后客户端去主动连接服务端随机打开的端口(默认是被动模式)

主动好还是被动好?

个人防火墙的默认一般只会拒绝进来的包,而不会拒绝你出去的包和你出去再回来的包。

所以上面的主动模式是有可能被拒绝掉的,一般的使用方法是:使用被动模式,并固定服务端的随机端口范围,在服务端写防火墙来控制

主动ftp对ftp服务器的管理有利,但对客户端的管理不利。因为是服务端主动与客户端去建立连接,可能会被客户端的防火墙把源来自服务器的包给阻塞掉

被动ftp对ftp客户端的管理有利,但对服务端的管理不利。因为客户端主动与服务端去连,可能会被服务端的防火墙给阻塞掉

折衷的方法就是使用被动模式,并指定一个连接过来的端口范围,可以针对这个范围的端口进行一个防火墙的设置。(到iptables课程会介绍)

验证被动模式和主动模式:

默认被动模式:

# ftp 192.168.1.128

Connected to 192.168.1.128 (192.168.1.128).

220 (vsFTPd 2.2.2)

Name (192.168.1.128:root): ftp

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using bi

nary mode to transfer files.

另一个终端验证:

# netstat -nt|grep 21

tcp        0      0 192.168.1.128:40095        192.168.1.128:21            ESTABLISHED  客户端连接server端21号端口

tcp        0      0 192.168.1.128:21            192.168.1.128:40095        ESTABLISHED  客户端连接server端打开的随机端口40095准备传输数据

# netstat -nt|grep 20 什么都没有

-l  监听状态 LISTENING(listening)|ESTABLISHED(established)

说明:

LISTENING:时表示处于侦听状态,就是说该端口是开放的,等待连接,但还没有被连接。就像你房子的门已经敞开的,但还没有人进来。

ESTABLISHED:意思是已建立连接。表示两台机器正在通信。

TIME_WAIT:意思是结束了这次连接。说明21端口曾经有过访问,但访问结束了

主动模式:

ftp> help passive

passive  enter passive transfer mode

ftp> passive  关闭被动模式

Passive mode off.

ftp> ls

200 PORT command successful. Consider using PASV.

150 Here comes the directory listing.

drwxr-xr-x    3 0        0            4096 Aug 07  2015 pub

226 Directory send OK.

另一个终端验证:

# netstat -nt|grep 20    server端的20号端口主动连接客户端的38054端口

tcp        0      0 192.168.1.128:20            192.168.1.128:38054        TIME_WAIT

FTP客户端工具:

linux下:lftp(默认匿名用户)|ftp|sftp

windows:firefox(浏览器)|Filezila

思路:

1、防火墙selinux关闭

2、yum配置ok

3、查询需要安装的包|安装|查看软件列表

4、了解配置文件

5、根据需求通过修改配置文件来完成ftp服务的搭建

6、启动服务,开机自启动

7、测试

# rpm -qc vsftpd

rpm -ql vsftpd

/etc/logrotate.d/vsftpd        –日志轮循

/etc/pam.d/vsftpd       –认证模块

/etc/rc.d/init.d/vsftpd       –启动脚本

/etc/vsftpd

/etc/vsftpd/ftpusers          –用户列表<拒绝用户登录ftp>

/etc/vsftpd/user_list          –用户列表<拒绝与允许>

/etc/vsftpd/vsftpd.conf        –主配置文件

/etc/vsftpd/vsftpd_conf_migrate.sh

/usr/sbin/vsftpd              –二进制命令

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS              –虚拟主机

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS              –虚拟用户

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2

/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README

/usr/share/man/man5/vsftpd.conf.5.gz

/usr/share/man/man8/vsftpd.8.gz

/var/ftp          ftp匿名用户的家目录  ftp://192.168.0.1/notes  == file:///var/ftp/noes

/var/ftp/pub      ftp扩展目录

1040  cp vsftpd.conf vsftpd.conf.bak

1041  grep -v ^# vsftpd.conf

1042  grep -v ^# vsftpd.conf |grep -v ^$

1043  grep -v ^# vsftpd.conf |grep -v ^$|tee vsftpd.conf

默认情况,配置文件不做修改

anon——代表匿名用户选项

local——代表本地用户 /etc/passwd文件里所存在的用户

# cat /etc/vsftpd/vsftpd.conf |grep -v ‘#’

anonymous_enable=YES  匿名用户可以访问

local_enable=YES  本地用户可以访问

write_enable=YES  可写总开关

local_umask=022    默认权限

dirmessage_enable=YES  启用用户家目录里的.messages

xferlog_enable=YES    启用日志

connect_from_port_20=YES  支持主动模式(默认是被动模式)

xferlog_std_format=YES  日志格式

listen=YES  独立服务

pam_service_name=vsftpd  认证模块

userlist_enable=YES    启用用户列表

tcp_wrappers=YES      支持tcp_wrappers访问控制,类似防火墙

demo1:配置文件不做任何修改,启动服务

service vsftpd start

1、匿名用户可以下载文件

2、本地用户可以上传下载,并且可以删除

demo2:允许匿名用户上传文件,并且可以删除文件

anon_mkdir_write_enable=YES 创建文件

anon_upload_enable=YES  上传文件

anon_other_write_enable=YES 删除、重命名等功能

client:

lftp 10.1.1.1:/> put file1

put: Access failed: 553 Could not create file. (file1)

lftp 10.1.1.1:/> mkdir abc

mkdir: Access failed: 550 Create directory operation failed. (abc)

原因:server端目录的权限不够

解决:chmod o+w /var/ftp

# lftp 10.1.1.1

lftp 10.1.1.1:~> ls

ls: Login failed: 500 OOPS: vsftpd: refusing to run with writable anonymous root

原因:匿名用户的默认数据根目录(/var/ftp)权限太大

解决:chmod o-w /var/ftp

终极解决:

chmod o+w /var/ftp/pub

demo3:下载其他匿名用户的文件

anon_umask=022

file:644

dir:755

只要文件具有r的权限就可以下载

demo4:开启本地用户和匿名用户消息功能

anon:/var/ftp

local:/home/username

# echo “welcome to user1 home” >/home/user1/.message

# echo “welcome to anon home” > /var/ftp/.message

启用消息:banner_file

banner_file=/etc/vsftpd/banner

demo5:指定匿名用户上传文件的所有人

自己完成

demo6:禁锢本地用户的家,只能在自己的家中活动,不能cd

禁锢大部分,允许小部分:

chroot_local_user=YES  禁锢所有人不能跳转

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list  该文件没有,自己创建;允许小部分人可以跳转

echo user1 >> /etc/vsftpd/chroot_list

允许大部分,禁锢小部分:

# chroot_local_user=YES 关闭

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list  禁锢小部分人

echo user1 >> /etc/vsftpd/chroot_list

demo7:ftp自身的访问控制

/etc/vsftpd/ftpusers  拒绝列表

echo user1 >> ftpusers

Name (10.1.1.1:root): user1

331 Please specify the password.

Password:

530 Login incorrect.

Login failed.

/etc/vsftpd/user_list

1、如果userlist_deny=NO;只允许该文件里的用户登录访问

2、如果userlist_deny=YES;不允许该文件里的用户登录

# cat user_list

# vsftpd userlist

# If userlist_deny=NO, only allow users in this file

# If userlist_deny=YES (default), never allow users in this file, and

# do not even prompt for a password.

# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers

Name (10.1.1.1:root): user1

530 Permission denied.

Login failed.

ftp> user stu1

530 Permission denied.

Login failed.

如果ftpusers和user_list文件冲突,ftpusers优先

demo8:指定匿名用户和本地用户上传文件的目录

/var/ftp

/home/username

anon_root=/data/anon

local_root=/data/local

lftp和ftp工具区别:

lftp可以批量并且下载目录

mirror remote local  下载整个目录到本地

mirror -R local remote  rename 上传整个目录到远程同时可以重命名

其他访问控制:

max_clients:访问的最大链接数 默认是2000

max_per_ip:单个客户端最大连接数  默认50

local_max_rate:限制本地用户下载速率,默认没有限制

local_max_rate=1000 单位是字节 1k

tcp_wrappers:是一款访问控制工具,类似iptables,但是功能没有iptables强大,并且配置比较简单。

/etc/hosts.allow

/etc/hosts.deny

访问控制机制先去匹配/etc/hosts.allow,再去匹配/etc/hosts.deny;如果两个都没有,全都允许;如果两个都有,以hosts.allow优先

不是所有服务都支持。

1).configure –enable-libwrap  表示支持tcp_wrappers访问控制

2)rpm安装

判断服务是否支持?

# ldd /usr/sbin/sshd |grep libwrap

libwrap.so.0 => /lib64/libwrap.so.0 (0x00007fc141877000)

vim /etc/hosts.deny

vsftpd:all ——全部拒绝

vsftpd:all  EXCEPT 192.168.0.2  拒绝所有除了192.168.0.2

等于

vim /etc/hosts.allow

vsftpd:all

vsftpd:192.168.0.2:deny

vsftpd:192.168.0.254  ——拒绝单个ip地址 等于在hosts.allow文件里增加vsftpd:192.168.0.254:deny

vsftpd:192.168.0.0/255.255.255.0 ——拒绝某个网段

vsftpd:192.168.0.0/255.255.255.0 EXCEPT 192.168.0.254  ——拒绝某个网段,但是除了某个ip地址

注意:子网掩码不支持192.168.0.0/24这种写法

sshd,vsftpd:all

被动连接模式,控制服务器数据传输端口的范围

vim /etc/vsftpd/vsftpd.conf

在最后加上

pasv_enable=YES –这一句默认不加也可以

pasv_min_port=3000

pasv_max_port=3005 –最小端口范围和最大端口范围可以自定义

–然后使用ftp 登录后,输入ls使之有数据传输,netstat -nt去验证查看会发现端口一定会在3000到3005范围内

课堂练习:

搭建一个自己的ftp服务器,要求:

1、匿名用户可以上传下载文件,同时也可以下载其他人所上传的文件,并且所有匿名用户上传的文件都放在/anon/data目录下。

anon_upload_enable=YES

anon_umask=022

anon_root=/anon

mkdir /anon/data -p

2、创建一个本地用户zhangsan(自己名字),可以访问你的ftp服务器,但是不能登录ftp服务器的操作系统,并且只能在自己的家目录中活动。

useradd -s /sbin/nologin zhangsan

/home/zhangsan

#chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list

或者

chroot_local_user=YES

echo zhangsan >> chroot_list

3、zhangsan(自己名字)用户可以上传下载文件,并且所有本地用户上传的文件都存放在/local/data.

local_root=/local/data

mkdir /local/data -p

4、在你的本地主机的/tmp/zhangsan(自己名字)下面创建5个文件,叫file{1..5},通过客户端工具以匿名用户身份将整个以你名字命名的目录上传到服务器172.16.13.74上

1017  mkdir /tmp/zhangsan

1018  touch /tmp/zhangsan/file{1..5}

1019  lftp 172.16.13.74

lftp 172.16.13.74:~> user zhangsan

Password:

lftp zhangsan@172.16.13.74:~> mirror -R /tmp/zhangsan/ ./lisi

5、使用客户端工具(除了浏览器)用本地用户stu1用户(密码123)下载172.16.13.74上的“2017-08-01”文件到你本地/tmp/zhangsan(自己名字)

lftp stu1@172.16.13.74:~> mirror 2017-08-01/ /tmp/zhangsan/

Total: 1 directory, 3 files, 0 symlinks

New: 3 files, 0 symlinks

6、不允许172.16.13.250访问你的ftp服务,但是只允许172.16.13.74访问。

/etc/hosts.deny

vsftpd:all  EXCEPT 172.16.13.74

作业:搭建一个ftp服务,要求如下:

1、只能在工作时间访问ftp服务 9:30到12:00 下午2:00到5:30

2、ftp服务的最大并发量为10,每个ip地址最大只能连接2次

3、登录失败2次直接断开连接

4、将ftp的日志保存到/var/log/ftp.log文件里,并按照以下方式轮转:

1>、保留5天的日志文件

2>、每天轮询一次

3>、以时间命名

4>、创建与原日志同名的新文件

service ftp

{

disable = no

socket_type        = stream

wait                = yes

user                = root

server              = /usr/sbin/vsftpd

instances          = 10

per_source = 2

log_on_success      += DURATION HOST USERID

access_times        = 9:30-12:00 14:00-17:30

log_type = FILE /var/log/ftp.log

}

问题:

# ftp 172.16.13.74

Connected to 172.16.13.74 (172.16.13.74).

421 Service not available, remote server has closed connection

原因:

wait = yes 表示该服务以单线成方式运行

This attribute determines if the  service  is  single-threaded  or

multi-threaded and whether or not xinetd accepts the connection or

the server program accepts the connection. If its  value  is  yes,

the  service is single-threaded; this means that xinetd will start

the server and then it will stop handling requests for the service

until the server dies and that the server software will accept the

connection. If the attribute value is no, the  service  is  multi-

threaded  and  xinetd  will keep handling new service requests and

xinetd will  accept  the  connection.  It  should  be  noted  that

udp/dgram  services  normally expect the value to be yes since udp

is not connection  oriented,  while  tcp/stream  servers  normally

expect the value to be no.

# lftp 172.16.13.74

lftp 172.16.13.74:~> ls

虚拟主机:

基于IP地址的虚拟主机

基于端口的虚拟主机

基于IP的虚拟主机

需求:

访问10.1.1.1 提供匿名用户下载功能,限速500kbps,匿名用户的家目录是/amy/ftp

访问172.16.13.74 提供用户[vip/123]上传下载文件,并且可以删除、修改、创建、只能在自己的家里活动功能,不限速

思路:

1、根据不同的去创建不同的配置文件

2、根据不同的ip地址去读取相应的配置文件

步骤:

1、配置两个IP地址

2、安装软件

3、根据需求搭建基于IP的虚拟主机

<1>生成虚拟主机各自的配置文件

1)提供匿名用户下载功能,限速500kbps,匿名用户的家目录是/amy/ftp

# cat vsftpd1.conf

anonymous_enable=YES

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

listen=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

anon_root=/amy/ftp

anon_max_rate=500000

listen_address=10.1.1.1

/etc/vsftpd/vsftpd1.conf

anonymous_enable=YES

local_enable=YES

write_enable=YES

local_umask=022

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

listen=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

anon_max_rate=512000  限速字节

anon_root=/amy/ftp  指定默认家目录

listen_address=192.168.1.10  监听地址

2)提供用户[vip/123]上传下载文件,并且可以删除、修改、创建、只能在自己的家里活动功能

vsftpd2.conf

anonymous_enable=YES

local_enable=YES

write_enable=YES

local_umask=022

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

listen=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list

listen_address=192.168.1.11

<2> 创建相应的目录及用户

mkdir /amy/ftp/pub -p

useradd amy

echo 123|passwd –stdin amy

<3>启动服务

# netstat -tnlp|grep vsftpd

tcp        0      0 192.168.1.10:21            0.0.0.0:*                  LISTEN      3693/vsftpd

tcp        0      0 192.168.1.11:21            0.0.0.0:*                  LISTEN      3688/vsftpd

# ps -ef|grep vsftpd

root      3688    1  0 20:31 ?        00:00:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd2.conf

root      3693    1  0 20:31 ?        00:00:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

<4>测试验证

[root@node2 Desktop]# lftp 10.1.1.1

lftp 10.1.1.1:~> ls

lftp 10.1.1.1:/> ls

-rw-r–r–    1 0        0              4 Aug 01 09:11 test

lftp 10.1.1.1:/> get test

4 bytes transferred

lftp 10.1.1.1:/> exit

[root@node2 Desktop]# ftp 10.1.1.1

Connected to 10.1.1.1 (10.1.1.1).

220 (vsFTPd 2.2.2)

Name (10.1.1.1:root): user1

530 This FTP server is anonymous only.

Login failed.

# ftp 172.16.13.74

Connected to 172.16.13.74 (172.16.13.74).

220 (vsFTPd 2.2.2)

Name (172.16.13.74:root): ftp

331 Please specify the password.

Password:

530 Login incorrect.

Login failed.

ftp>

ftp>

ftp> user user1

331 Please specify the password.

Password:

230-welcome to user1 home

230 Login successful.

ftp>

ftp>

ftp> ls

227 Entering Passive Mode (172,16,13,74,94,115).

150 Here comes the directory listing.

drwxr-xr-x    2 516      516          4096 Aug 01 02:50 NEWB

drwxr-xr-x    2 516      516          4096 Aug 01 02:49 abc

226 Directory send OK.

ftp> pwd

257 “/”

# route add -net 10.1.1.0/24 dev eth0

基于端口的虚拟主机

需求:

访问172.16.13.74的21端口 提供匿名用户上传下载功能,并且最大连接数20,每个ip最大连接数为2

访问172.16.13.74的2121端口 提供用户 上传下载功能,默认数据目录为/amy/data,并且最大登录失败次数为2

步骤:

1、清空环境  ifconfig eth0:0 down

2、修改各自的配置文件

1)访问192.168.0.1的21端口 提供匿名用户上传下载功能,并且最大连接数20,每个ip最大连接数为2

# cat vsftpd.conf

anonymous_enable=YES

local_enable=YES

write_enable=YES

local_umask=022

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

listen=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

anon_max_rate=512000

anon_root=/amy/ftp

anon_upload_enable=YES

anon_mkdir_write_enable=YES

anon_other_write_enable=YES

max_clients=20

max_per_ip=2

listen_port=21

2)访问192.168.0.1的2121端口 提供用户 上传下载功能,默认数据目录为/amy/data,并且最大登录失败次数为2,

# cat vsftpd2.conf

anonymous_enable=YES

local_enable=YES

write_enable=YES

local_umask=022

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

listen=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

chroot_local_user=YES

listen_port=2121

max_login_fails=2

local_root=/amy/data

3)重启服务

4)测试验证

# netstat -nltp|grep vsftpd

tcp        0      0 0.0.0.0:21                  0.0.0.0:*                  LISTEN      9668/vsftpd

tcp        0      0 0.0.0.0:2121                0.0.0.0:*                  LISTEN      9673/vsftpd

虚拟用户:

yum -y remoce vsftpd

yum -y install vsftpd

less /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration

Step 1) Create the virtual users database.

1) 定义txt文档 奇数行定义用户名 偶数行为密码

# vim /etc/vsftpd/logins.txt

stu1

123

stu2

123

stu3

123

2) 将txt文件转换成db文件

# db_load -T -t hash -f /etc/vsftpd/logins.txt /etc/vsftpd/login.db

3) 修改权限

# chmod 600 /etc/vsftpd/login.db

Step 2) Create a PAM file which uses your new database.

1) 查找pam的认证用户的db文件

# find / -name pam_userdb.so

/lib64/security/pam_userdb.so

2) 新建pam文件来验证db文件 /etc/vsftpd/login.db

# vim /etc/pam.d/vsftpd

auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/login

account required /lib64/security/pam_userdb.so db=/etc/vsftpd/login

Step 3) Set up the location of the files for the virtual users.

[root@mor vsftpd]# useradd -d /home/ftpsite virtual

[root@mor vsftpd]# ll -d /home/ftpsite/

drwx—— 4 virtual virtual 4096 Jun  8 10:07 /home/ftpsite/

定义测试文件提供下载

cp /etc/hosts /home/ftpsite

chown virtual.virtual /home/ftpsite/hosts

Step 4) Create your vsftpd.conf config file.

vim /etc/vsftpd/vsftpd.conf

anonymous_enable=NO  禁止匿名用户访问

local_enable=YES  非匿名用户

write_enable=NO  写总开关

anon_upload_enable=NO  上传

anon_mkdir_write_enable=NO

anon_other_write_enable=NO

chroot_local_user=YES  禁锢自己的家里

guest_enable=YES  激活虚拟用户

guest_username=virtual  定义匿名用户

listen=YES

listen_port=10021 端口

anon_world_readable_only=NO  –可以查看到下载的文件<开启读写功能>

Step 5) Start up vsftpd.

service vsftpd start

Step 6) Test.

ftp 192.168.0.1

Connected to 192.168.0.1 (192.168.0.1).

220 (vsFTPd 2.2.2)

Name (192.168.0.1:root): a

331 Please specify the password.

Password: –123

230 Login successful.

本地用户和虚拟用户同在:

# cat /etc/pam.d/vsftpd

#%PAM-1.0

auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/login

account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/login

session    optional    pam_keyinit.so    force revoke

auth      required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed

auth      required pam_shells.so

auth      include password-auth

account    include password-auth

session    required    pam_loginuid.so

session    include password-auth

问题:本地用户和虚拟用户的数据根目录为不同的目录,如何实现?

需求:

1、用户u1 提供下载 限速200KBps  /home/ftpsite/u1

2、用户u2 提供上传 限速 500KBps  /home/ftpsite/u2

3、用户u3 超级vip 不限速 可以上传与下载  /home/ftpsite

思路:

针对不同的用户定义不同的子配置文件

步骤:

1.主配置文件中定义用户的配置文件<子配置文件>存放在那个位置

vim /etc/vsftpd/vsftpd.conf

user_config_dir=/etc/vsftpd/conf

mkdir /etc/vsftpd/conf

2.按照用户的需求生成用户的配置文件

用户u1 提供下载 限速200KBps  /home/ftpsite/u1

vim  /etc/vsftpd/conf/u1

local_root=/home/ftpsite/u1

anon_max_rate=200000

anon_world_readable_only=NO

用户u2 提供上传 限速 50KBps  /home/ftpsite/u2

vim  /etc/vsftpd/conf/u2

local_root=/home/ftpsite/u2

anon_world_readable_only=YES

write_enable=YES

anon_upload_enable=YES

anon_max_rate=50000

用户u3 超级vip 不限速 可以上传与下载  /home/ftpsite

vim /etc/vsftpd/conf/u3

local_root=/home/ftpsite

anon_world_readable_only=NO

anon_max_rate=0

anon_upload_enable=YES

write_enable=YES

anon_mkdir_write_enable=YES

anon_other_write_enable=YES

3.新建用户家目录

mkdir /home/ftpsite/u1

mkdir /home/ftpsite/u2

chown virtual.virtual -R /home/ftpsite/

4 重启服务

service vsftpd restart

5测试

    原文作者:柒夏锦
    原文地址: https://www.jianshu.com/p/17596cc133e0
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞