+3 votes
268 views
How to change FTP port (21) on Linux

in Linux / Unix by (552k points)
reopened | 268 views

1 Answer

+4 votes
Best answer

Modify port 21 by default FTP of Linux

In Linux we have various protocols that give us the possibility of carrying out administrative, communication and many other tasks..

One of these, known to all, is the FTP (File Transfer Protocol) protocol through which we can make transfers between several computers.

A good security practice is to modify the default FTP port to prevent attackers from accessing it, today we will see how to achieve it..

To keep up, remember to subscribe to our YouTube channel! SUBSCRIBE

Modify port 21 by default FTP of Linux

Step 1

To modify the default port of the Proftpd service on Linux, we must open the main Proftpd configuration file to edit the desired editor like this:
 sudo nano /etc/proftpd.conf (CentOS and RedHat) sudo nano /etc/proftpd/proftpd.conf (Debian and Ubuntu) 
Step 2

When accessing this file, we will locate the “Port” line and see that the default port (21) is: image
Step 3

There it is enough to edit the port for which we want, in this case 7777: image
Step 4

We save the changes using the following key combination:

+ O Ctrl + O

We leave the editor using:

+ X Ctrl + X

Note
In case of not having proftpd we can install it using the following command:
 sudo apt install proftpd-basic 
Step 5

In the case of RedHat or CentOS the line will be called "Port 21". Once this step is done, we will execute the following.
  • Restart proftpd service:
 systemctl restart proftpd 
  • Check that the new port is the one assigned:
 netstat -tlpn | grep ftp 
  • Or the command:
 ss -tlpn | grep ftp 
image
Step 6

In the case of CentOS or RedHat we will use the following lines:
 yum install policycoreutils week port -a -t http_port_t -p tcp 2121 week port -m -t http_port_t -p tcp 2121 systemctl restart proftpd 
It's that simple to change the FTP port on Linux and improve security.

by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Nov 1, 2019 in Linux / Unix by backtothefuture (552k points) | 292 views
+5 votes
1 answer
asked Nov 6, 2020 in Linux / Unix by backtothefuture (552k points) | 318 views
+5 votes
1 answer
+5 votes
1 answer
asked May 8, 2021 in Linux / Unix by backtothefuture (552k points) | 336 views
+3 votes
1 answer
asked May 8, 2021 in Linux / Unix by backtothefuture (552k points) | 351 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users