Linux ftp изменить порт

Как изменить порт FTP в Linux

FTP или протокол передачи файлов — один из старейших сетевых протоколов, используемых сегодня в качестве стандартной передачи файлов по компьютерным сетям. Протокол FTP использует стандартный порт 21/TCP в качестве командного порта. Хотя существует множество реализаций протокола FTP на стороне сервера в Linux, в этом руководстве мы расскажем, как изменить номер порта в реализации службы Proftpd.

Чтобы изменить порт по умолчанию службы Proftpd в Linux, сначала откройте основной файл конфигурации Proftpd для редактирования в вашем любимом текстовом редакторе, выполнив приведенную ниже команду. Открытый файл имеет разные пути, специфичные для вашего собственного установленного дистрибутива Linux, как показано ниже.

# nano /etc/proftpd.conf [On CentOS/RHEL] # nano /etc/proftpd/proftpd.conf [On Debian/Ubuntu]

В файле proftpd.conf найдите и прокомментируйте строку, начинающуюся с Порт 21. Вам нужно добавить хэштег (#) перед строкой, чтобы прокомментировать строку.

Затем под этой строкой добавьте новую строку порта с новым номером порта. Вы можете добавить любой нестандартный TCP-порт от 1024 до 65535 при условии, что новый порт еще не занят в вашей системе другим приложением, которое связывается с ним.

В этом примере мы привяжем службу FTP к порту 2121/TCP.

В дистрибутивах на основе RHEL строка Порт отсутствует в файле конфигурации Proftpd. Чтобы изменить порт, просто добавьте новую строку порта в верхней части файла конфигурации, как показано в приведенном ниже отрывке.

После изменения номера порта перезапустите демон Proftpd, чтобы применить изменения, и введите команду netstat, чтобы подтвердить, что служба FTP прослушивает новый порт 2121/TCP.

# systemctl restart proftpd # netstat -tlpn| grep ftp OR # ss -tlpn| grep ftp

В дистрибутивах на основе CentOS или RHEL Linux установите пакет policycoreutils и добавьте приведенные ниже правила SELinux, чтобы демон FTP мог связываться с >2121 порт.

# yum install policycoreutils # semanage port -a -t http_port_t -p tcp 2121 # semanage port -m -t http_port_t -p tcp 2121 # systemctl restart proftpd

Наконец, обновите правила брандмауэра дистрибутива Linux, чтобы разрешить входящий трафик через новый FTP-порт. Кроме того, проверьте диапазон пассивных портов FTP-сервера и убедитесь, что вы также обновили правила брандмауэра, чтобы отразить диапазон пассивных портов.

Читайте также:  Vmware tools linux iso image

Источник

How to Change FTP Port in Linux

FTP or File Transfer Protocol is one of the oldest network protocol used today as standard file transfers over computer networks. FTP protocol uses the standard port 21/TCP as command port. Although, there are a lot of implementations of FTP protocol in server-side in Linux, in this guide we’ll cover how to change the port number in the Proftpd service implementation.

In order to change Proftpd service default port in Linux, first open Proftpd main configuration file for editing with your favorite text editor by issuing the below command. The opened file has different paths, specific to your own installed Linux distribution, as follows.

# nano /etc/proftpd.conf [On CentOS/RHEL] # nano /etc/proftpd/proftpd.conf [On Debian/Ubuntu]

In proftpd.conf file, search and comment the line that begins with Port 21. You need to add a hashtag (#) in front of the line in order to comment the line.

Then, under this line, add a new port line with the new port number. You can add any TCP non-standard port between 1024 to 65535, with the condition that the new port is not already taken in your system by other application which binds on it.

In this example we’ll bind FTP service on port 2121/TCP.

Change FTP Port in Debian & Ubuntu

In RHEL based distributions, the Port line is not present in Proftpd configuration file. To change the port, just add a new port line at the top of the configuration file, as illustrated in the below excerpt.

Change FTP Port in CentOS & RHEL

After you’ve changed the port number, restart the Proftpd daemon to apply changes and issue netstat command to confirm that FTP service listens on the new 2121/TCP port.

# systemctl restart proftpd # netstat -tlpn| grep ftp OR # ss -tlpn| grep ftp

Confirm FTP Port

Under CentOS or RHEL Linux based distributions, install policycoreutils package and add the below SELinux rules in order for the FTP daemon to bind on the 2121 port.

# yum install policycoreutils # semanage port -a -t http_port_t -p tcp 2121 # semanage port -m -t http_port_t -p tcp 2121 # systemctl restart proftpd

Finally, update your Linux distribution firewall rules in order to allow inbound traffic on the new FTP port. Also, check FTP server passive port range and make sure you also update the firewall rules to reflect passive port range.

Читайте также:  Zabbix agent linux настройка

Источник

How to Change FTP Port in Linux

change ftp port in linux

By default, FTP services run on port 21. However, since these are publicly known port numbers used by almost every FTP service, it may pose a security issue with attackers trying to access this port. Changing FTP port number is one of the simplest ways to secure FTP services on your network. There are many FTP services available for use. We will learn how to change FTP port number in Proftpd service.

How to Change FTP Port in Linux

Here are the steps to change FTP port in Linux. You need to follow the same steps for almost every FTP service. We will basically open its configuration file in a text editor, change the port number mentioned in it, save and close the file, and then restart the FTP service.

1. Open configuration file

Depending on your Linux distribution, run the following command to open configuration file for Proftpd.

# vi /etc/proftpd.conf [On CentOS/RHEL] # vi /etc/proftpd/proftpd.conf [On Debian/Ubuntu]

Similarly, if you want to change port number of VSFTPD, open its config file.

$ sudo vi /etc/vsftp/vsftpd.conf or / $ sudo vi etc/vsftpd.conf

2. Change Port Number

You will see the following line.

Change it to 2000, as shown below, to change the FTP port to 2000. You can use a port number as per your requirement.

3. Restart Proftpd

Restart Proftpd service with the following commands.

# systemctl restart proftpd # netstat -tlpn| grep ftp OR # ss -tlpn| grep ftp

If you are running RHEL/CentOS systems, run the following commands to install policycoreutils and add SELinux rules to bind FTP to port 2000.

# yum install policycoreutils # semanage port -a -t http_port_t -p tcp 2000 # semanage port -m -t http_port_t -p tcp 2000 # systemctl restart proftpd

Finally, update your system’s firewall to allow traffic through port 2000.

Читайте также:  Gimp one window linux

As mentioned earlier, it is always advisable to change the FTP port on your system to make it difficult for attackers to guess and exploit vulnerabilities.

Источник

Оцените статью
Adblock
detector