aliyun Centos7安装vsftpd服务

一。什么是vsftpd

  vsftpd(very secure FTP daemon) ,是一个有很高安全性的运行在类UNIX上的FTP服务器。为了高安全性,它运行在chroot模式下,chroot模式就是为程序单独指定一个新的目录,它也就不能访问这个目录以外的内容了。

二。什么是FTP

FTP会话时包含了两个通道(都为tcp):

控制通道:控制通道是和FTP服务器进行沟通的通道,连接FTP,发送FTP指令都是通过控制通道来完成的。

数据通道:数据通道是和FTP服务器进行文件传输或者列表的通道。

FTP协议中,控制连接均有客户端发起,而数据连接有两种工作方式:PORT方式和PASV方式(参考[3])。

三。vsftpd的安装

1.安装vsftpd

yum install vsftpd

2.添加ftp帐号与目录

由于上面说到的vsfpt的chroot模式(prevent from accessing other directories),我们最好为FPT专门创建不可以通过ssh登录的用户。

useradd -d /home/ftp1 -s /sbin/nologin ftp1

上面命令中的-s后面的就是指定ftp1用户使用nologin shell。

修改新建用户的密码

passwd ftp1

如果用户之前是使用的login shell,我们可以通过

usermod -s /sbin/nologinshell you_username

来remove SSH access.到目前为上,我们如果使用FTP连接,还是会出下面的ERROR:

ERROR:500 OOPS:vsftpd refusing to run with writable root inside chroot().

我们查看/home/ftp1的权限(权限格式为:文件所有者-文件所属组-其它人对此文件的权限)可以发现,此时文件所有者依然有w权限。所以

chmod a-w /home/ftp1

3.配置vsftp

修改vsftpd的配置文件

vim /etc/vsftpd/vsftpd.conf

如果我们不允许anonymous和未认证的用户登录,则将如下项改为NO。

anonymous_enable=NO

允许本地用户登录:

local_enable=YES

允许本地用户write to a directory:

write_enable=YES本地用户将chroot jaied and be denied access to any other part of the server:

chroot_local_user=YES

4.修改shell配置

查看/etc/shells,如果文件里面没有/usr/sbin/nologin或者/sbinnologin,则追加进去。

5.启动

systemctl restart vsftpd

设置成开机自启动

systemctl enble vsftpd

参考:

[1] http://www.liquidweb.com/kb/how-to-install-and-configure-vsftpd-on-centos-7/

[2] http://www.liquidweb.com/kb/error-500-oops-vsftpd-refusing-to-run-with-writable-root-inside-chroot-solved/

[3] http://os.51cto.com/art/201008/222036.htm

原文地址:https://www.cnblogs.com/chuiyuan/p/5116892.html