使用Vsftpd服务传输文件

本文详细介绍了如何在RedHat7.0系统上安装与配置vsftpd版本3.0.2搭建FTP服务器的过程。包括安装vsftpd、配置本地用户与虚拟用户模式、设置防火墙与SELinux、以及启动与管理服务等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#搭建ftp服务器
说明:
操作系统:Red Hat 7.0
vsftpd版本:3.0.2
目标:
通过配置ftp服务器,向外提供文件传输服务
##安装vsftpd服务器

# yum install vsftpd -y  

安装vsftpd

###备份配置文件

# mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.confbak
# grep -v "#" /etc/vsftpd/vsftpd.confbak > /etc/vsftpd/vsftpd.conf

###查看默认配置文件

# cat /etc/vsftpd/vsftpd.conf

anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
###使用默认配置启动vsftpd

# systemctl start vsftpd
# systemctl status vsftpd

vsftpd状态
###添加系统服务

systemctl enable vsftpd

ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'

###防火墙设置(防火墙配置请参考配置iptables或firewalld配置)

systemctl stop firewalld.service

# systemctl stop  iptables.service
# 关闭selinux

###匿名登陆

ftp匿名访问模式是不安全的服务模式,正式环境不允许匿名登陆

匿名登陆
##配置ftp
###配置本地用户模式

# cat /etc/vsftpd/vsftpd.conf

anonymous_enable=NO #禁止匿名访问
local_enable=YES #允许本地用户模式
write_enable=YES #允许写入
local_umask=022 #本地用户文件umask值
userlist_deny=YES #禁止list中的用户值为NO则为仅允许名单
userlist_enable=YES #允许"禁止登陆名单",名单文件为ftpuser与user_list
dirmessage_enable=YES #是否激活目录欢迎信息功能
xferlog_enable=YES #记录服务器上传和下载情况的日志文件
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
tcp_wrappers=YES

重启服务:

# systemctl restart vsftpd.service

查看禁止登陆用户:
禁止登陆用户

添加普通用户:

# useradd moxiaokai
# passwd moxiaokai
    Changing password for user moxiaokai.
    New password: 
    BAD PASSWORD: The password is a palindrome
    Retype new password: 
    passwd: all authentication tokens updated successfully.

在客户端尝试登陆ftp:
普通用户登陆
###配置虚拟用户模式
####添加虚拟用户:

单行为账号,双行为密码

# cd /etc/vsftpd/
# vi vuser.list
    moxiaokai
    pa33word
    cy
    pa22word

####生成数据库文件:
生成库文件:

# db_load -T -t hash -f vuser.list vuser.db
# file vuser.db 
    vuser.db: Berkeley DB (Hash, version 9, native byte-order)

授权:

# chmod 600 vuser.db 

删除原始文件:

# rm -f vuser.list

####创建ftp根目录及虚拟用户映射系统用户

# useradd -d /var/ftproot/ -s /sbin/nologin vmxk
# chmod -Rf 755 /var/ftproot/

####建立PAM文件

vim /etc/pam.d/vsftpd.vu

    auth       required     pam_userdb.so db=/etc/vsftpd/vuser
    account    required     pam_userdb.so db=/etc/vsftpd/vuser

####配置vsftp

vim /etc/vsftpd/vsftpd.conf

    anonymous_enable=NO
    local_enable=YES
    guest_enable=YES
    guest_username=vmxk
    write_enable=YES
    local_umask=022
    dirmessage_enable=YES
    xferlog_enable=YES
    connect_from_port_20=YES
    xferlog_std_format=YES
    listen=NO
    listen_ipv6=YES
    pam_service_name=vsftpd.vu
    userlist_enable=YES
    tcp_wrappers=YES
    allow_writeable_chroot=YES
    user_config_dir=/etc/vsftpd/vusers_dir

创建目录&文件:

# mkdir /etc/vsftpd/vusers_dir
# cd /etc/vsftpd/vusers_dir
# touch moxiaokai
# vim moxiaokai
    anon_upload_enable=YES
    anon_mkdir_write_enable=YES
    anon_other_write_enable=YES

重启vsftpd服务:

# systemctl restart vsftpd.service

使用虚拟用户登录:
虚拟用户登录

转载于:https://blog.51cto.com/309173854/2043395

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值