离线安装步骤:
(在线安装的,直接通过yum安装就行,很简单)
1、查看是否安装vsftp
rpm -qa | grep vsftpd
- 1
- 2
2、下载vsftp
ftp://rpmfind.net/linux/centos/6.7/os/x86_64/Packages/vsftpd-2.2.2-14.el6.x86_64.rpm
- 1
- 2
来源: http://rpmfind.net/linux/rpm2html/search.php?query=vsftpd(x86-64)
3、安装vsftp
rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm
- 1
- 2
4、开启ftp
service vsftpd start
- 1
- 2
5、测试是否ftp服务是否成功运行
5.1 ps -ef | grep ftp 查看是否有相应的进程存在
5.2 通过浏览器访问 ftp://192.168.124.46/pub
6、配置vsftpd
# whereis vsftpd
vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz
- 1
- 2
- 3
rpm、yum安装的主要目录为上述3个目录,其中配置文件 vsftpd.conf 在/etc/vsftpd中,下面看下怎么配置vsftpd.conf
6.1 备份:
cd /etc/vsftpd; cp vsftpd.conf vsftpd.conf_bak
- 1
- 2
6.2 编辑
vsftpd.conf 里面有很多的配置项,这里只列出一部分常用的配置项
#下面是配置的选项及说明
# 允许本地用户登录
local_enable=YES
# 本地用户的写权限
write_enable=YES
# 修改连接端口
#listen_port=2121
######### 匿名登录设置 ###########
# 允许匿名登录
anonymous_enable=NO
#### 限制目录
# 限制所有用户都在家目录
#chroot_local_user=yes
# 调用限制在家目录的用户名单
chroot_list_enable=YES
# 限制在家目录的用户名单所在路径
chroot_list_file=/etc/vsftpd/chroot_list
######### 日志设置 ###########
# 日志文件路径设置
xferlog_file=/var/log/vsftpd.log
# 默认情况下,vsftpd 是用GMT做为它的时间的,所以和操作系统的时间不一致!!!
# 所以加入下面这一行,来同步vsftpd与操作系统的时间
use_localtime=YES
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
7、修改ftp防火墙规则
/sbin/iptables -I INPUT -p tcp --dport 21 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
- 1
- 2
- 3
- 4
(或者直接关闭防火墙 —— service iptables stop)
8、添加用户(注意,该处添加nologin类型用户ftpuser)
useradd -d /home/ftpuser -s /sbin/nologin ftpuser
#设置密码
passwd ftpuser
- 1
- 2
- 3
- 4
- 5
9、重新启动
service vsftpd stop
service vsftpd start
- 1
- 2
- 3
10、安装客户端
下载
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/ftp-0.17-54.el6.x86_64.rpm
- 1
- 2
安装
rpm -ivh ftp-0.17-54.el6.x86_64.rpm
- 1
- 2
11、使用ftp命令在本机进行测试
ftp <本机ip> <ftp端口>
#输入用户名
#输入密码
#ls查看ftp目录
- 1
- 2
- 3
- 4
- 5
12、实体账号登录设置
CentOS的FTP是不允许实体帐号登录取得用户目录数据的,需要进行设置:
getsebool -a | grep ftp
setsebool -P ftp_home_dir=1