1.检测是否已安装FTP服务
# rpm -qa|grep vsftpd
2.未安装ftp服务的前提进行使用rpm安装
# yum install vsftpd -y
Loaded plugins: securitybase | 3.7 kB 00:00epel| 4.7 kB 00:00epel/primary_db | 6.0 MB 00:00extras| 3.4 kB 00:00extras/primary_db | 29 kB 00:00updates| 3.4 kB 00:00updates/primary_db | 5.8 MB 00:00Setting up Install Process
Resolving Dependencies-->Running transaction check---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be installed-->Finished Dependency Resolution
Dependencies Resolved===========================================================================================Package Arch Version Repository Size===========================================================================================Installing:
vsftpd x86_642.2.2-24.el6 base 156k
Transaction Summary===========================================================================================Install1Package(s)
Total download size:156k
Installed size:340k
Downloading Packages:
vsftpd-2.2.2-24.el6.x86_64.rpm | 156 kB 00:00Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.2-24.el6.x86_64 1/1Verifying : vsftpd-2.2.2-24.el6.x86_64 1/1Installed:
vsftpd.x86_640:2.2.2-24.el6
Complete!
下载并安装完成。
3.启动服务
# service vsftpd start
Starting vsftpd for vsftpd: [ OK ]
启动ftp命令#service vsftpd start
停止ftp命令#service vsftpd stop
重启ftp命令#service vsftpd restart
4.配置FTP参数
4.1 匿名用户
#vim /etc/vsftpd/vsftpd.conf --编辑配置文件
anonymous_enable=NO --修改配置项 禁止匿名登录
#anon_upload_enable=YES 上传
#anon_mkdir_write_enable=YES 创建
#anon_other_write_enable=YES 删除
#service vsftpd restart
4.2 创建一个用户和密码
#useradd -s /sbin/nologin testaccount --创建账号
#passwd testaccount--为创建好的账号进行设置密码
Changing passwordforuser viong.
New password:
BAD PASSWORD: itisbased on a dictionary word
Retypenewpassword:
passwd: all authentication tokens updated successfully.
4.3 设置用户只限于访问自身目录
vim /etc/vsftpd/vsftpd.conf--在最后一行加上
chroot_list_enable=YES -- //限制访问自身目录
# (defaultfollows)
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
切入到/etc/vsftpd目录
编辑 vsftpd.chroot_list文件,将受限制的用户添加进去,每个用户名一行
[root@gray-web vsftpd]# vim vsftpd.chroot_list
zzbftp-- 添加需要受限制的用户名
修改完成 重启ftp服务
[root@gray-web vsftpd]# service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpdfor vsftpd:
5.测试连接并上传文件
命令: LIST
错误: 无法打开传输通道。原因:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
错误: 无法取得目录列表
搭建好后使用8UFTP发现连接成功,但是响应列表超时了。原因是因为防火墙里面需要设置为主动模式,但是按理说主动模式还更容易出问题,但是测试吧FTP客户端改成主动模式后,顺利登陆FTP服务器,至此问题解决。
修改后连接成功: