Linux下vsftpd的安装配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下vsftpd的安装配置相关的知识,希望对你有一定的参考价值。

一、安装
由于很多时候都是在没有网络的情况下安装,所以下载rpm包来安装,我这里环境如下:
系统:redhat enterprise 6.5
vsftpd安装包:vsftpd-3.0.2-21.el7.x86_64.rpm

1、安装

rpm -ivh vsftpd-3.0.2-21.el7.x86_64.rpm

2、测试是否安装成功

[[email protected] ~]# service vsftpd start
  为 vsftpd 启动 vsftpd:[确定]

二、配置

[[email protected] ~]#cd /etc/vsftpd

备份: cp vsftpd.conf vsftpd.conf_bak
编辑: vi vsftpd.conf

1、关闭匿名登录
关闭匿名登录可增强安全性,防止×××轻易占领你的电脑
anonymous_enable=NO

2、锁定根目录
锁定根目录同样提高安全性,防止用户访问到本不在FTP范围内的文件,同时,类似光闸服务等业务都需要锁定根目录才能运行。
chroot_local_user = YES

`vi /etc/vsftpd/chroot_list
``
在文件内加入可以访问的用户,每个用户名一行

3、端口控制
先查看iptables设置
iptables -nL
将21号端口插入到INPUT的ACCEPT中
iptables -I INPUT 5 -p tcp --dport 21 -j ACCEPT  ## rulenum为5 ,在INPUT中REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited之前
插入到INPUT的ACCEPT后查看
#iptables -nL --line-numbers

4、添加用户
            useradd -d /home/ftp -s /sbin/nologin ftp
  passwd ftp
  输入用户密码
             再次输入密码
  重新启动
  service vsftpd stop
  service vsftpd start

5、selinux的相关设置项
#setsebool -P ftp_home_dir 1 
#setsebool -P allow_ftpd_full_access 1

6、关闭防火墙
永久性生效
开启:chkconfig iptables on
关闭:chkconfig iptables off
即时生效,重启后失效
开启:service iptables start
关闭:service iptables stop

7、设置自启动
[[email protected] /]# chkconfig --list|grep vsftpd
vsftpd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
上面显示vsftpd 在linux任何工作等级下都没有自启动
[[email protected] /]# chkconfig vsftpd on
上面这条命令设置vsftpd自启动
[[email protected] /]# chkconfig --list|grep vsftpd
vsftpd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
上面显示表明vsftpd在Linux工作2,3,4,5等级下都会自启动服务。

三、用命令行测试

ftp <ip> <端口>
ftp> get test.html a.html(回车)
ftp> dir (回车)
ftp> bye(回车) 退出 ftp 模式

以上是关于Linux下vsftpd的安装配置的主要内容,如果未能解决你的问题,请参考以下文章

linux学习记录-----vsftpdf服务安装配置

Linux环境下配置vsftpd的虚拟用户

Linux下安装FTP服务器及配置方法

linux下安装vsftp服务

CentOS 6.4下安装vsftpd配置虚拟用户登录

linux 下 安装 vsftpd