CentOS 7 vsftpd 搭建 FTP
来源:互联网 发布:神经网络算法能做什么 编辑:程序博客网 时间:2024/05/16 17:27
1. 安装 vsftpd
(1) 检查是否安装 vsftpd 软件
#rpm -qa | grep vsftpd
(2)没有安装就进行安装
#yum -y install vsftpd
(3)设置 vsftpd 自启动
#chkconfig vsftpd on
(4)常用操作
#service vsftpd start // 启动 vsftpd 服务器#service vsftpd restart // 重启 vsftpd 服务器#service vsftpd stop // 停止 vsftpd 服务器#service vsftpd status // 查询 vsftpd 服务器
2. 配置 vsftpd 虚拟用户
(1) 修改 vftpd.conf 配置文件
#vim /etc/vsftpd/vsftpd.conf// 是否允许匿名用户登录anonymous_enable=YES/NO// 是否允许本地用户登录, 如果为 NO, 虚拟用户也无法登录local_enable=YES// 本地用户是否锁定在宿主目录中chroot_list_enable=YES// 指定用户列表文件chroot_list_file=/etc/vsftpd/chroot_list// 支持 ASCII 的上传功能ascii_upload_enable=YES// 支持 ASCII 的下载功能ascii_download_enable=YES// 设置 PAM 认证服务配置文件名, PAM 将根据 /etc/pam.d/vsftpd 文件进行认证pam_service_name=vsftpd// 启用虚拟用户guest_enable=YES// 设置虚拟用户宿主, CentOS 已经内置 ftp 用户guest_username=ftp// 设置用户配置文件所在目录(配置文件名跟虚拟用户名一致)user_config_dir=/etc/vsftpd/vuser_conf
(2)创建 chroot_list 文件
# 在 /etc/vsftpd/ 文件夹中创建 chroot_list 文件, 里面写入 ftp 即可。[root@localhost vsftpd]# echo ftp >> chroot_list
(3)创建用户密码文件
在 /etc/vsftpd/ 中创建 vuser_password.txt
[root@localhost vsftpd]# vim vuser_password.txt
vuser_password.txt 文件内容:
nukix // 奇数行, 虚拟用户名123456 // 偶数行, 密码
(4)使用 db_load 工具将列表文本文件转为数据库文件
[root@localhost vsftpd]# db_load -T -t hash -f /etc/vsftpd/vuser_password.txt /etc/vsftpd/vuser_password.db
生成的 db 文件在 /etc/vsftpd/vuser_password.db
注: 如果没有安装可以安装 db4-utils 。
(5)编辑认证文件
# vim /etc/pam.d/vsftpd
把里面所有项注释掉(前面加#), 然后后面根据系统加入不同的行
32位系统:
- auth required pam_userdb.so db=/etc/vsftpd/vuser_password
- account required pam_userdb.so db=/etc/vsftpd/vuser_password
64位系统:
- auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_password
- account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_password
64位系统如下:
#%PAM-1.0#session optional pam_keyinit.so force revoke#auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed#auth required pam_shells.so#auth include password-auth#account include password-auth#session required pam_loginuid.so#session include password-authauth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwordaccount required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_password
(6)创建虚拟用户配置文件
在 /etc/vsftpd/ 下执行
# 创建 vuser_conf 文件夹[root@localhost vsftpd]# mkdir vuser_conf// 进去 vuser_conf 文件夹[root@localhost vsftpd]# cd vuser_conf# 创建 nukix 文件, 这个文件名必须跟虚拟用户名一致, 不然无效[root@localhost vuser_conf]vim nukix
nukix 文件内容如下:
local_root=/home/ftp # 虚拟用户根目录, 必须有读写权限 chmod -R 777 目录名write_enable=YES # 允许在文件系统写入权限anon_umask=022 # 匿名用户上传文件默认权限掩码值anon_world_readable_only=NO # 允许匿名用户浏览整个服务器的文件系统anon_upload_enable=YES # 开启匿名帐号的上传功能anon_mkdir_write_enable=YES # 允许创建文件夹anon_other_write_enable=YES # 允许其他的写入权限
(7) 开启服务
#service vsftpd start
注意, 如果不禁用 SELinux 的 FTP 传输审核功能则会出现如下错误: “500 OOPS: 无法改变目录”。
SELinux 在 /etc/selinux/ 位置, config 为配置文件, 默认配置文件内容如下:
# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of three two values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection.SELINUXTYPE=targeted
附录
常见问题
1. Q: 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
A: vsftpd 新版本不允许根目录有写入的权限, 需要在 vsftpd.conf 中加入 allow_writeable_chroot=YES。
- CentOS 7 vsftpd 搭建 FTP
- [积累] CentOS 配置 vsftpd 搭建 ftp 服务
- CentOS 6.8 使用vsftpd搭建ftp
- linux centos FTP服务器搭建vsftpd配置
- CentOS 7 安装FTP服务器(vsftpd)
- Centos(linux)下VSFTPD搭建FTP服…
- 阿里云CentOS使用vsftpd搭建FTP服务器
- Linux CentOS 6.5 下 vsftpd ftp服务器搭建
- Linux CentOS 6.5 下配置vsftpd 搭建FTP服务器
- vsftpd 搭建 ftp
- vsftpd ftp服务器搭建
- CentOS 搭建 vsftpd
- CentOS 搭建 vsftpd
- CentOS下安装vsftpd(FTP)
- centos 7 搭建 ftp 服务器
- CentOS 7搭建FTP服务器
- centos 7 ftp 服务器搭建
- CentOS 7安装配置vsftpd做FTP服务
- Qt鼠标事件使用总结
- Java核心编程之异常的捕获及处理
- Android studio lambda环境配置
- 解决修改CSS文件后网页显示不生效问题
- Ubuntu 16.04 TLS Samba配置
- CentOS 7 vsftpd 搭建 FTP
- 网络编程复习(三):NIO模式
- CentOS 6 网络设置
- Makefile
- 【DBA基础篇】-oracle用户登陆
- codevs 1966 乘法游戏
- Java 9 Module的特性以及解决的问题
- c++设计模式六,适配器模式
- 一起来学SpringCloud之