How to change the FTP port for PureFTP

Introduction

If you want to change the port that for PureFTP from default port 21 to something custom, you will need to modify the configuration file then restart the service.

Procedure to change the FTP port for PureFTP

1. Use your preferred text editor, such as vi or nano to create or edit the /var/cpanel/conf/pureftpd/local file.

2. Set the port number the to the port of your choosing using the “Bind” variable. Make sure that you select a port that is not already in use by another service, and ensure that the port is not blocked by your firewall software or otherwise inaccessible. An example of this file’s contents when setting “Bind” is included below:

# cat /var/cpanel/conf/pureftpd/local
Bind: 21

3. To apply your changes, perform a force update of FTP with the following command:

# /scripts/setupftpserver pure-ftpd --force

4. Confirm the FTP service is now listening on the new port number. For example, I used port 6021:

# lsof -P -n -i :6021
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
pure-ftpd 21249 root 4u IPv4 6547868 0t0 TCP *:6021 (LISTEN)
pure-ftpd 21249 root 5u IPv6 6547869 0t0 TCP *:6021 (LISTEN)

5. Be sure to also update the port listed in the file /usr/local/cpanel/src/chkservd/chkserv.d/ftpd (shown as 6021 below). This will ensure that the service is able to be properly monitored:

# cat /usr/local/cpanel/src/chkservd/chkserv.d/ftpd
service[ftpd]=6021,QUIT,220,/usr/local/cpanel/scripts/restartsrv_ftpserver,proftpd||pure-ftpd&&pure-authd,root|nobody,220|USER %service_auth_user%|3|PASS %service_auth_pass%|2|QUIT

6. Restart chkservd so that the change is applied to /etc/chkserv.d/ftpd:

/scripts/restartsrv_chkservd

For more information visit our documentation:

source: https://support.cpanel.net/hc/en-us/articles/1500000487261-How-to-change-the-FTP-port-for-PureFTPd

This is a simple guide on how to change the FTP port for PureFTP service in cPanel servers.

Tags: , ,