Centos6配置开启FTP Server

vsftpd作为FTP服务器,在Linux系统中是非常常用的。下面我们介绍如何在centos系统上安装vsftp。

什么是vsftpd

vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序。特点是小巧轻快,安全易用。

vsftpd 的名字代表”very secure FTP daemon”, 安全是它的开发者 Chris Evans 考虑的首要问题之一。在这个 FTP 服务器设计开发的最开始的时候,高安全性就是一个目标。

当前系统版本:

[root@AAA ~]# cat /proc/version 
Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014
[root@AAA ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel 
 on an m

(1)安装vsftpd:

[root@AAA ~]# yum install vsftpd

(2)设置开机启动vsftpd ftp服务:

[root@AAA ~]# chkconfig vsftpd on

(3)启动vsftpd服务:

[root@AAA ~]# chkconfig vsftpd on
[root@AAA ~]# service vsftpd on
Usage: /etc/init.d/vsftpd {start|stop|restart|try-restart|force-reload|status}
[root@AAA ~]# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]

(4)配置vsftpd服务器

vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
#anonymous_enable=YES

chroot_local_user=YES
#去掉前面的注释

#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
#不受限制的用户列表,用不用都OK

(5)配置防火墙并重启防火墙:

[root@AAA ~]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
[root@AAA ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

本机测试ftp root:

C:Usersuname>ftp 10.60.9.4
Connected to 10.60.9.4.
220 (vsFTPd 2.2.2)
User (10.60.9.4:(none)): root
331 Please specify the password.
Password:
230 Login successful.
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    4 0        0            4096 Mar 08  2016 Desktop
drwxr-xr-x    2 0        0            4096 Dec 25  2015 Documents
drwxr-xr-x    2 0        0            4096 Dec 25  2015 Downloads
...

附录(Centos6.6上设置vsftpd并没有出现如下错误):

假如出现错误
1500 OOPS: cannot change directory
解决方法:
在终端输入命令:
setsebool -P ftpd_disable_trans 1
service vsftpd restart
就OK了!
原因:这是因为服务器开启了selinux,这限制了FTP的登录。
原文地址:https://www.cnblogs.com/z-joshua/p/6589434.html