Ubuntu 16.04LTS vsftpd 安装指南

安装

zhiwei tan
Jul 30, 2017 · 3 min read

sudo apt-get install vsftpd

什么是xinetd模式和initd模式

像其它守护程序一样,vsftpd提供了standalone和inetd(inetd或xinetd)两种运行模式。简单解释一下, standalone一次性启动,运行期间一直驻留在内存中,优点是对接入信号反应快,缺点是损耗了一定的系统资源,因此经常应用于对实时反应要求较高的专业FTP服务器。inetd恰恰相反,由于只在外部连接发送请求时才调用FTP进程,因此不适合应用在同时连接数量较多的系统。此外,inetd模式不占用系统资源。除了反应速度和占用资源两方面的影响外,vsftpd还提供了一些额外的高级功能,如inetd模式支持per_IP(单一IP)限制,而 standalone模式则更有利于PAM验证功能的应用。

配置

配置项说明

// 如果设置为YES,则vsftpd将以独立模式运行,由vsftpd自己监听和处理IPv4端口的连接请求

listen=YES

// 不允许匿名用户登录

anonymous_enable=NO

// 允许本地用户登录,本地用户指存在于 /ect/passwd 中的用户

local_enable=YES

// 是否允许本地用户对FTP服务器文件具有写权限

write_enable=YES

// 是否让系统自动维护上传和下载的日志文件

// 默认情况该日志文件为 /var/log/vsftpd.log, 也可以通过下面的xferlog_file选项对其进行设定

// 默认值为NO

xferlog_enable=YES

// 用户登录FTP服务器后是否具有访问自己目录以外的其他文件的权限

// 设置为YES时,用户被锁定在自己的home目录中,vsftpd将在下面chroot_list_file选项值的位置寻找chroot_list文件

// 必须与下面的设置项配合

chroot_list_enable=YES

// 被列入此文件的用户,在登录后将不能切换到自己目录以外的其他目录

// 从而有利于FTP服务器的安全管理和隐私保护。此文件需自己建立

chroot_list_file=/etc/chroot_list

// 设置PAM外挂模块提供的认证服务所使用的配置文件名,即 /etc/pam.d/vsftpd 文件

// 此文件中 file=/etc/ftpusers 字段,说明了PAM模块能抵挡的帐号内容来自文件 /etc/ftpusers 中

pam_service_name=vsftp // 注意:这里值要设为 vsftp 而不是 vsftpd(default),否则会出现530错误

// 设置允许 /etc/vsftpd.user_list 文件中的用户登录FTP服务器

userlist_enable=YES

userlist_deny=NO

添加FTP用户

sudo useradd -d /var/ftp -s /usr/sbin/nologin username

修改用户密码

passwd username

将用户添加到 /etc/vsftpd.user_list

restart 服务

sudo systemctl restart vsftpd.service

查看服务状态

sudo systemctl status vsftpd.service

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade