首页 > Linux运维 > CentOS > centos7/rhel7安装vsftpd
2019
03-20

centos7/rhel7安装vsftpd

centos7/rhel7安装vsftpd
环境:

[root@laofuxi.com ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core)


[root@laofuxi.com ~]# getenforce 
Enforcing

安装

[root@laofuxi.com ~]# yum -y install vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.yun-idc.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-25.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                          Arch                                             Version                                                   Repository                                      Size
==================================================================================================================================================================================================================
Installing:
 vsftpd                                           x86_64                                           3.0.2-25.el7                                              base                                           171 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package

Total download size: 171 k
Installed size: 353 k
Downloading packages:
vsftpd-3.0.2-25.el7.x86_64.rpm                                                                                                                                                             | 171 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : vsftpd-3.0.2-25.el7.x86_64                                                                                                                                                                     1/1 
  Verifying  : vsftpd-3.0.2-25.el7.x86_64                                                                                                                                                                     1/1 

Installed:
  vsftpd.x86_64 0:3.0.2-25.el7                                                                                                                                                                                    

Complete!

添加到开机启动

[root@laofuxi.com ~]# systemctl enable vsftpd.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

修改配置文件

[root@laofuxi.com ~]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
修改为
anonymous_enable=NO

#chroot_local_user=YES
修改为
chroot_local_user=YES

#xferlog_file=/var/log/xferlog
修改为
xferlog_file=/var/log/xferlog

添加参数
pasv_enable=YES
pasv_min_port=9000
pasv_max_port=9900

allow_writeable_chroot=YES


修改后,完整参数如下:

[root@localhost ~]# grep -v "^#\|^$" /etc/vsftpd/vsftpd.conf 
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
chroot_local_user=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
pasv_enable=YES
pasv_min_port=9000
pasv_max_port=9900
allow_writeable_chroot=YES

selinux修改

[root@laofuxi.com ~]# setsebool -P ftpd_use_passive_mode on
[root@laofuxi.com ~]# setsebool -P ftpd_full_access on

修改认证参数

[root@localhost ~]# vim /etc/pam.d/vsftpd

注释掉下面这一行
#auth       required    pam_shells.so

重启vsftpd服务

[root@laofuxi.com ~]# systemctl restart vsftpd.service

查看监听端口

[root@laofuxi.com ~]# ss -tunlp | grep vsftpd
tcp    LISTEN     0      32       :::21                   :::*                   users:(("vsftpd",pid=17189,fd=4))

firewalld防火墙开放21、9000-99000端口

[root@laofuxi.com ~]# firewall-cmd --permanent --add-port=21/tcp --add-port=9000-9900/tcp --zone=public 
success
[root@laofuxi.com ~]# firewall-cmd --reload 
success

[root@laofuxi.com ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192
  sources: 
  services: ssh dhcpv6-client
  ports: 8080/tcp 10000/tcp 80/tcp 21/tcp 9000-9900/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
	

添加测试用户

[root@laofuxi.com ~]# useradd -s /usr/sbin/nologin alao
[root@laofuxi.com ~]# passwd alao
Changing password for user alao.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

测试效果
centos7/rhel7安装vsftpd - 第1张  | 劳福喜博客-专注Linux服务器运维技术

最后编辑:
作者:劳福喜博客
这个作者貌似有点懒,什么都没有留下。

留下一个回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据