CentOS / RHEL : How to configure vsftpd to use ports other than the default ports 20 and 21

Very Secure FTP Daemon (vsftpd) is the most secure and fastest FTP server. By default the vsftp server runs on the port 20 and 21. As a security recommendation, in some organizations system admins tend to change the port from the default ports 20 and 21 to some other ports. The post describes steps to change the default ports to the port numbers you want.

Changing default ports for vsftpd

1. Edit the configuration file /etc/vsftp/vsftpd.conf and add the below 2 lines to change the listening port and data originate port to something else:

# /etc/vsftp/vsftpd.conf
listen_port=A
ftp_data_port=B

Here,
A – listening port.
B – data originate port.

For example if you want the vsftpd service to run on ports 2020 and 2121 respectively, add below lines to the configuration file /etc/vsftp/vsftpd.conf.

# /etc/vsftp/vsftpd.conf
listen_port=2020
ftp_data_port=2121

The port number can be changed to a different number according to the requirements or environment. Make sure that the selected port will be used is currently not being used by any other services. Check the file /etc/services for a list of all assigned port numbers and have a look at the # netstat -plan output to get a list of currently used ports.

2. Restart the service after you have modified the configuration file:

# service vsftpd restart
Related Post