centos

CentOS FTP Server端口设置指南

小樊
50
2025-09-17 21:26:41
栏目: 智能运维

CentOS FTP Server Port Setting Guide

This guide provides step-by-step instructions for configuring FTP server ports on CentOS, focusing on vsftpd (the most commonly used FTP server in CentOS). The process includes modifying the configuration file, adjusting firewall rules, and testing the connection.

1. Install vsftpd

If vsftpd is not already installed, use the following command to install it:

sudo yum install vsftpd -y

2. Start and Enable vsftpd Service

Start the vsftpd service and configure it to start automatically on system boot:

sudo systemctl start vsftpd
sudo systemctl enable vsftpd

3. Modify vsftpd Configuration File

Edit the vsftpd main configuration file (/etc/vsftpd/vsftpd.conf) using a text editor (e.g., vi or nano):

sudo vi /etc/vsftpd/vsftpd.conf

Key Port-Related Configurations

4. Restart vsftpd Service

Apply the configuration changes by restarting the vsftpd service:

sudo systemctl restart vsftpd

5. Configure Firewall

Allow the new FTP command port and passive mode port range through the firewall (using firewalld, the default firewall tool in CentOS):

For firewalld

6. Test FTP Connection

Verify the FTP server is accessible on the new port using an FTP client (e.g., ftp command-line tool or FileZilla):

ftp localhost 2121  # Replace 2121 with your custom port

Enter your FTP username and password when prompted. If the connection succeeds, the port configuration is correct.

Optional: Disable SELinux (if applicable)

If SELinux is enforcing, it may block FTP connections. To temporarily disable SELinux (not recommended for production):

sudo setenforce 0

To permanently disable SELinux, edit /etc/selinux/config and set SELINUX=disabled, then reboot the server.

Security Recommendations

0
看了该问题的人还看了