How to change ftp port – cpanel

The ftp – service is for file transfer. The default port for ftp services are 20 and 21.

Port 20: Data transfer port
Port 21: Connection port

How to change ftp port – cPanel ?
We can change the default value of ftp port from its configuration file. The first and importent step is to find which ftp service is currently running on the server.

Step 1: SSH to server:

[root@spr ]# ssh root@IpAddress

Step 2: Find the ftp service:

[root@server ]# netstat -ntlp|grep :21
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      3582/pure-ftpd (SER
tcp        0      0 :::21                       :::*                        LISTEN      3582/pure-ftpd (SER

In this case the ftp server is pure-ftpd.

Step 3: Change the port number:
3.1 : Pure-FTP
The configuration file for Pure-FTP service is ‘/etc/pure-ftpd.conf’
Edit the conf file:

[root@server ]# vim  /etc/pure-ftpd.conf
-----
# IP address/port to listen to (default=all IP and port 21).
# Bind                      127.0.0.1,21
-----
:wq

Edit /etc/chkserv.d/ftpd and change the port, which is the first comma-separated entry to the right of ‘=’ on the line in the file, to match the port you put the service on. Then restart the service.

[root@server ]# /etc/init.d/pure-ftpd restart 
[root@server ]# /etc/init.d/cpanel restart (restarts tailwatchd/chkservd) 

3.2 : ProFTP
The configuration file is ‘/etc/proftpd.conf’. Edit /etc/proftpd.conf and change the port value.

[root@server ]# vim /etc/proftpd.conf
-------
Port                   21
-------
:wq

Then restart the service:


[root@server ]# /etc/init.d/proftpd start
[root@server ]# /etc/init.d/cpanel restart (restarts tailwatchd/chkservd) 

Step 4: If necessary, add the new FTP port to your server’s firewall.

[root@server ]# iptables -A INTUP -p tcp --dport "new" -j ACCEPT
[root@server ]# iptables -A OUTTUP -p tcp --dport "new" -j ACCEPT

Thank you.

Related links:
How to reset SSH port from WHM
How to change cpanel port through command line
How to change the apache port via command line in cpanel

,

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

2 thoughts on “How to change ftp port – cpanel

Leave a Reply

Your email address will not be published. Required fields are marked *