目录
✅ 1. Install vsftpd
✅ 2. Configure vsftpd (/etc/vsftpd/vsftpd.conf)
✅ 3. Create an FTP User (Optional but Recommended)
✅ 4. Configure Firewall
✅ 5. Test the FTP Server
✅ Bonus: SELinux (if enabled)
首页 运维 CentOS 如何在CentOS中设置FTP服务器

如何在CentOS中设置FTP服务器

Aug 06, 2025 am 09:11 AM

安装vsftpd并启动服务;2. 配置/etc/vsftpd/vsftpd.conf禁用匿名登录、启用本地用户写入和chroot锁定;3. 创建专用FTP用户并可选限制其仅FTP访问;4. 开放防火墙FTP服务及被动模式端口;5. 从客户端测试连接并根据需要调整SELinux策略,即可搭建一个安全可用的FTP服务器,适合内部或遗留应用使用,建议避免暴露在公网并考虑升级到FTPS以增强安全性。

How to set up an FTP server in CentOS

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:

How to set up an FTP server in CentOS

✅ 1. Install vsftpd

First, update your system and install vsftpd:

sudo yum update -y
sudo yum install vsftpd -y

Start and enable the service:

How to set up an FTP server in CentOS
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:

How to set up an FTP server in CentOS
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 in
  • write_enable=YES → Allow file uploads/modifications
  • chroot_local_user=YES → Lock users to their home directories
  • allow_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

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中文网其他相关文章!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

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

热门文章

Rimworld Odyssey如何钓鱼
1 个月前 By Jack chen
Kimi K2:最强大的开源代理模型
1 个月前 By Jack chen
我可以有两个支付帐户吗?
1 个月前 By 下次还敢

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

热门话题

Laravel 教程
1602
29
PHP教程
1506
276
实时内核补丁的kernelcare和kpatch是什么? 实时内核补丁的kernelcare和kpatch是什么? Jul 12, 2025 am 01:07 AM

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

如何在防火墙中添加或删除服务? 如何在防火墙中添加或删除服务? Jul 13, 2025 am 01:32 AM

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

CentOS中的主要系统日志文件在哪里? CentOS中的主要系统日志文件在哪里? Jul 19, 2025 am 03:56 AM

在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轮换日志、实

如何在CentOS中格式化新磁盘 如何在CentOS中格式化新磁盘 Aug 03, 2025 am 08:19 AM

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

如何为自动化CentOS安装配置Kickstart文件? 如何为自动化CentOS安装配置Kickstart文件? Jul 18, 2025 am 01:40 AM

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

如何在CentOS中配置网络键合 如何在CentOS中配置网络键合 Jul 27, 2025 am 03:44 AM

确保系统已加载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配

如何更改CentOS中的用户密码 如何更改CentOS中的用户密码 Jul 26, 2025 am 07:37 AM

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

如何安装软件包的特定版本? 如何安装软件包的特定版本? Jul 14, 2025 am 01:12 AM

安装特定版本的包可通过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)统一管理依赖版本,确保环

See all articles