奥塔在线:Centos7下vsftp服务的安装及部署

1、vsftp是什么?

百度百科上是这样说明的:vsftp是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,它的全称是Very Secure FTP 。

维基百科是这样介绍它的

VSFTPD: Very Secure File Transfer Protocol Deamon

VSFTPD stands for "Very Secure FTP Daemon" is a GPL licensed FTP server for UNIX systems. It is licensed under the GNU General Public License. It supports IPv6 and SSL. vsftpd supports explicit (since 2.0.0) and implicit (since 2.1.0) FTPS. vsftpd is the default FTP server in the Ubuntu, CentOS, Fedora, NimbleX, Slackware and RHEL Linux distributions. It is secure and extremely fast. It is stable. VSFTPD is a mature and trusted solution which supports virtual users with PAM (pluggable authentication modules). A virtual user is a user login which does not exist as a real login on the system in /etc/passwd and /etc/shadow file. Virtual users can therefore be more secure than real users, because a compromised account can only use the FTP server but cannot login to system to use other services such as SSH or SMTP.

In July 2011, it was discovered that VSFTPD version 2.3.4 downloadable from the master site had been compromised. Users logging into a compromised vsftpd-2.3.4 server may issue a ":)" smiley-face as the username and gain a command shell on port 6200. This was not an issue of a security hole in VSFTPD, instead, someone had uploaded a different version of VSFTPD which contained a backdoor. Since then, the site was moved to Google App Engine.

 简单来说,vsftp是Linux下比较受推崇的FTP服务,它致力于搭建一套安全、高速、稳定的FTP服务。

然而,它是哪个大神编码的,一直没查到,值得尊重的无名英雄。

2、vsftp的安装

#查看是否安装了ftp服务
rpm -q vsftpd

#安装FTP服务
yum -y install vsftpd

 安装很简单。使用yum方式安装完成后,程序目录在/etc/vsftpd。

该目录下默认有4个文件

ftpusers 拒绝访问名单(黑名单)
user_list 允许访问名单(白名单 -->是否白名单由配置中userlist_deny参数决定)
vsftpd.conf 主配置文件
vsftpd_conf_migrate.sh 文件迁移脚本(将/etc目录下的FTP相关文件迁移到/etc/vsftpd目录)

3、vsftp的部署(配置)

#添加ftp用户,指定访问路径及不允许进行登录 /sbin/false 表示禁止登陆
useradd ftpaccount -d /mnt/ftproot -g ftps -s /sbin/nologin

#查看ftp服务默认配置
cat /etc/vsftpd/vsftpd.conf | grep -v '^#'

配置文件(vsftpd.conf)中基本参数说明:

anonymous_enable=NO  #是否允许匿名用户访问
local_enable=YES     #是否允许本地用户登录
write_enable=YES     #是否允许本地用户写入
local_umask=022      #本地用户上传文件的umask
dirmessage_enable=YES  #为YES 当切换目录时显示此目录下由message_file选项指定的文本文件(默认为.message)的内容
xferlog_enable=YES     #开启上传下载日志
xferlog_std_format=YES   #日志采用标准格式
xferlog_file=/var/log/xferlog   #ftp日志存储目录
connect_from_port_20=YES  #启用FTP数据端口的连接请求

idle_session_timeout=6000     #设置客户端连接超时时间 空闲用户回话中断时间
data_connection_timeout=1200  #设置数据连接超时时间 针对上传,下载空闲中断时间
max_clients=200  #限制客户端连接数
max_per_ip=3     #每个IP的连接数

local_max_rate=50000  #设置普通用户最大传输速率限制(Bps)
anon_max_rate=30000   #匿名用户最大传输速率限制(Bps)

#chroot_list配置 chroot == change root dir?
chroot_local_user=YES    #限制用户访问目录 YES 所有用户禁止跳出主目录 NO 所有用户可跳出主目录(具体执行策略还得和下面的chroot_list_enable配合)
chroot_list_enable=YES   #是否使用chroot_list 若为NO,则记录在chroot_list_file所指定的文件(默认是/etc/vsftpd.chroot_list)中的用户将被chroot在登录后所在目录中,无法离开.如果为YES,则所记录的用户将不被chroot.这里YES.
chroot_list_file=/etc/vsftpd/chroot_list #设置为YES则下面的控制有效

#userlist配置
userlist_enable=YES  #若为NO,则仅接受记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)中的用户的login请求.若为YES则不接受这些用户的请求.
userlist_deny=NO     #为YES时 在userlist_file选项指定的文件(默认是/etc/vsftpd/user_list)中的用户将无法登录FTP 为NO,则user_list中用户可登录FTP服务
userlist_file=/etc/vsftpd/user_list #白名单

local_root=/var/ftp/pub #所有用户默认根目录

listen=YES   #开启监听 使vsftpd处于独立启动模式  包括inetd和独立FTP两种运行方式
pam_service_name=vsftpd  #设置PAM认证服务的配置文件名称 该文件存放在/etc/pam.d目录下
tcp_wrappers=YES  #使用tcp_wrappers作为主机的访问控制方式

guest_enable=YES      #是否启用guest
guest_username=vsftpd  #使用虚拟账号模式
user_config_dir=/etc/vsftpd/userconfig #虚拟账号用户配置

按需求配置后,启动vsftpd服务。

systemctl start vsftpd  #centos7x

service vsftpd start  #centos6x

一般情况下,我们还会新增一个chroot_list文件,格式与ftpusers、user_list一样,一行一个用户账号。

/etc/vsftpd/chroot_list:指定允许使用vsftpd 的用户列表文件。

 对ftp用户访问的配置,可以参考下面这篇博文:

vsftpd 配置:chroot_local_user与chroot_list_enable详解

 

你可能感兴趣的:(Linux)