如何在CentOS中设置FTP服务器
安装vsftpd并启动服务;2. 配置/etc/vsftpd/vsftpd.conf禁用匿名登录、启用本地用户写入和chroot锁定;3. 创建专用FTP用户并可选限制其仅FTP访问;4. 开放防火墙FTP服务及被动模式端口;5. 从客户端测试连接并根据需要调整SELinux策略,即可搭建一个安全可用的FTP服务器,适合内部或遗留应用使用,建议避免暴露在公网并考虑升级到FTPS以增强安全性。
Setting up an FTP server on CentOS is straightforward — especially if you're using vsftpd
(Very Secure FTP Daemon), which is the default and most secure option. Here's how to do it step by step:

✅ 1. Install vsftpd
First, update your system and install vsftpd
:
sudo yum update -y sudo yum install vsftpd -y
Start and enable the service:

sudo systemctl start vsftpd sudo systemctl enable vsftpd
Check status:
sudo systemctl status vsftpd
✅ 2. Configure vsftpd (/etc/vsftpd/vsftpd.conf
)
Make a backup of the original config:

sudo cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.orig
Now edit the config file:
sudo nano /etc/vsftpd/vsftpd.conf
Key settings to change or confirm:
anonymous_enable=NO
→ Disable anonymous access (secure by default)local_enable=YES
→ Allow local system users to log inwrite_enable=YES
→ Allow file uploads/modificationschroot_local_user=YES
→ Lock users to their home directoriesallow_writeable_chroot=YES
→ Required if chroot directory is writable (common in CentOS 7 )
Optional but useful:
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100
→ These set up passive mode (needed for firewalls/NAT)
Save and exit (Ctrl O
, Enter
, Ctrl X
in nano).
Restart vsftpd:
sudo systemctl restart vsftpd
✅ 3. Create an FTP User (Optional but Recommended)
Don’t use root. Create a dedicated user:
sudo adduser ftpuser sudo passwd ftpuser
Set permissions if needed:
sudo chown ftpuser:ftpuser /home/ftpuser sudo chmod 755 /home/ftpuser
? Tip: You can restrict this user to only FTP access by setting their shell to
/sbin/nologin
:sudo usermod -s /sbin/nologin ftpuser
✅ 4. Configure Firewall
If using firewalld
(default in CentOS):
sudo firewall-cmd --permanent --add-service=ftp sudo firewall-cmd --permanent --add-port=40000-40100/tcp # for passive mode sudo firewall-cmd --reload
If using iptables
, adjust accordingly — but firewalld
is standard now.
✅ 5. Test the FTP Server
From another machine, test with:
ftp your-server-ip
Or use an FTP client like FileZilla — just enter:
- Host: your-server-IP
- Username: ftpuser
- Password: [your-password]
- Port: 21
If passive mode is set, make sure your client supports it (FileZilla does by default).
✅ Bonus: SELinux (if enabled)
CentOS often has SELinux enabled. If FTP login fails, try:
sudo setsebool -P ftp_home_dir on
Check SELinux status:
sestatus
That’s it!
You now have a working, secure FTP server on CentOS using vsftpd
. It’s not the most modern protocol (SFTP/FTPS are better for security), but FTP still has its place — especially for legacy apps or internal networks.
Just remember:
- Use strong passwords
- Avoid exposing FTP to the public internet unless necessary
- Consider using FTPS (FTP over SSL) for better security
Basically done — no magic, just solid config.
以上是如何在CentOS中设置FTP服务器的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undress AI Tool
免费脱衣服图片

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

KernelCare和kpatch均为实现Linux内核热补丁的工具,但适用场景不同。1.KernelCare是商业服务,支持CentOS、RHEL、Ubuntu和Debian,自动应用补丁且无需重启,适合托管服务商和企业生产环境;2.kpatch是红帽开发的开源工具,基于ftrace框架,需手动构建补丁模块,适用于RHEL及兼容系统,适合需要精细控制补丁过程或使用定制内核的组织。选择时应考虑自动化需求、系统分布、是否需要官方支持以及对开源工具的掌控程度。两者均无法修补所有漏洞,部分仍需重启,并

FirewallD如何添加或移除服务?1.添加服务:先用firewall-cmd--get-services查看可用服务,临时添加用--add-service=服务名,永久添加加--permanent参数;2.移除服务:用--remove-service=服务名临时移除,加--permanent永久移除,修改后均需执行--reload重载配置;3.自定义服务:用--new-service创建服务并编辑XML文件定义端口,之后按标准服务添加。操作时注意区分临时与永久设置,并及时重载防火墙。

在CentOS中,系统日志文件主要存储在/var/log目录下,常见的包括:1./var/log/messages记录系统消息;2./var/log/secure记录认证相关日志;3./var/log/dmesg记录内核信息;4./var/log/cron记录定时任务信息;5./var/log/boot.log记录启动过程。CentOS7及以上版本使用rsyslog管理日志,并结合systemd的journald工具,可通过journalctl命令查看,同时建议使用logrotate轮换日志、实

Identifythenewdiskusinglsblkorfdisk-ltolocatethecorrectdevicelike/dev/sdb.2.Optionallypartitionthediskwithfdisk/dev/sdb,createaprimarypartitionusingdefaultsettings,andwritechangeswithw,thenrunpartprobetoupdatethekernel.3.Createafilesystemusingmkfs-tx

ToconfigureakickstartfileforautomatedCentOSinstallation,startwithatemplate,customizeessentialsectionslikelanguage,disksetup,andpackageselection,placethefilewheretheinstallercanaccessit,andtestitviabootablemediaorPXE.Beginbycopyinganexistingsamplefrom

确保系统已加载bonding模块并确认网卡接口可用,使用modprobebonding和lsmod验证;2.创建/etc/sysconfig/network-scripts/ifcfg-bond0配置文件,设置DEVICE、TYPE、BONDING_MASTER、IP参数及BONDING_OPTS=mode=active-backupmiimon=100primary=ens33;3.配置物理网卡ens33和ens34的ifcfg文件,设置MASTER=bond0、SLAVE=yes并移除IP配

TochangeyourownpasswordinCentOS,runpasswdandenteryourcurrentpasswordfollowedbythenewpasswordtwice.2.Tochangeanotheruser’spassword,usesudopasswdusernameorrunpasswdusernameasroot,whichdoesnotrequiretheuser’soldpassword.3.Toforceausertochangetheirpasswo

安装特定版本的包可通过pip或npm实现。1.使用pip安装Python包时,在包名后加==和版本号,如pipinstallpackage_name==1.2.3,注意使用对应Python版本的pip并可结合镜像源加速;2.使用npm安装Node.js包时,在包名后加@和版本号,如npminstallpackage_name@1.2.3,同时可选择本地或全局安装;3.项目中通常通过requirements.txt(Python)或package.json(Node.js)统一管理依赖版本,确保环
