Ftp服务部署

一、安装 vsftpd

bash 复制代码
# Centos 安装 vsftpd
sudo yum install vsftpd -y

# Ubuntu 安装 vsftpd
sudo apt update
sudo apt install vsftpd -y

# 设置开机自启
sudo systemctl enable vsftpd

# 启动服务
sudo systemctl start vsftpd

# 查看服务状态(确认是否运行)
sudo systemctl status vsftpd

二、核心配置(匿名 / 本地用户模式)

安装完之后在/etc/vsftpd/路径下会存在几个配置文件

/etc/vsftpd/vsftpd.conf:vsftpd 的核心配置文件

/etc/vsftpd/ftpusers:用于指定哪些用户不能访问FTP 服务器(黑名单)

/etc/vsftpd/user_list:指定允许使用vsftpd 的用户列表文件(白名单)

/etc/vsftpd/chroot_list:指定允许使用vsftpd 的用户列表文件(控制名单下的目录能不能离开ftp根目录)

1.vsftpd.conf具体配置如下

bash 复制代码
anonymous_enable=NO  #允许匿名用户访问为了安全选择关闭
local_enable=YES   # 允许本地用户登录
write_enable=YES   # 是否允许写入
local_umask=022  # 本地用户上传文件的umask
dirmessage_enable=YES #为YES则进入目录时显示此目录下由message_file选项指定的文本文件(,默认为.message)的内容
xferlog_enable=YES #开启日志

xferlog_std_format=YES #标准格式
connect_from_port_20=YES
xferlog_file=/var/log/xferlog   #ftp日志目录

idle_session_timeout=6000 #设置客户端连接时间

data_connection_timeout=1200 #设置数据连接时间 针对上传,下载
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list #设置为YES则下面的控制有效
chroot_list_enable=YES #若为NO,则记录在chroot_list_file所指定的文件(默认是/etc/vsftpd.chroot_list)中的用户将被chroot在登录后所在目录中,无法离开.如果为YES,则所记录的用户将不被chroot.这里YES.
chroot_local_user=YES
userlist_deny=NO #若设置为YES则记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)中的用户将无法login,并且将检察下面的userlist_deny选项
userlist_enable=YES #若为NO,则仅接受记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)中的用户的login请求.若为YES则不接受这些用户的请求.
userlist_file=/etc/vsftpd/user_list #白名单
chroot_list_enable=YES
local_root=/var/ftp/pub #根目录
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

2.创建 FTP 本地用户并添加到user_list和chroot_list中去

bash 复制代码
# 创建用户 ftpuser
sudo useradd ftpuser

# 设置用户密码
sudo passwd ftpuser

# 授权目录权限
chmod 777 /var/ftp/pub
相关推荐
Johny_Zhao8 小时前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
YuMiao1 天前
gstatic连接问题导致Google Gemini / Studio页面乱码或图标缺失问题
服务器·网络协议
chlk1232 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑2 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件2 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
碳基沙盒2 天前
OpenClaw 多 Agent 配置实战指南
运维
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI3 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行4 天前
Linux和window共享文件夹
linux