Change vsftpd FTP Server Port Number 21

Posted on in Categories , , , , , last updated November 29, 2012

Because of security issues I would like to change the vsftpd server tcp port # 21. How do I configure vsftpd to use another port instead of the default TCP port 21? How to change vsftpd ftp port number in Linux or Unix?

vsftpd, which stands for Very Secure FTP Daemon, is an FTP server under Ubuntu, Fedora Core, Red Hat Enterprise Linux and a number of other distributions. Changing a default port is a good idea. FTP is a common method for allowing remote access to files. Like telnet, the FTP protocol is unencrypted, which means that passwords and other data transmitted during the session can be captured and that the session is vulnerable to hijacking.

Changing vsftp port

All you need to do is edit the configuration file for vsftpd server. The default configuration file is /etc/vsftp/vsftpd.conf or /etc/vsftpd.conf.

First login as root user.

Open the vsftpd.conf file, enter:
# vi vsftpd.conf

Find line that read as follows
listen_port=21

Replace port 21 with new port such as 201:
listen_port=201

Save and close the file. Please make sure no other service is using port # 201. Finally, restart the vsftpd server:
# /etc/init.d/vsftpd restart
OR
# service vsftpd restart

All ftp client need use the tcp port # 201 while connecting to the ftp server. For example:
$ ftp ftp.cyberciti.biz 201

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

13 comment

    1. Its a bug that Selinux wont allow vsftpd to be started if you have assigned the port which is less then 1024 except port number 21. Assign the port which greater than 1024, for e.g. try port 10000. vsftpd will not fail to start.

  1. You should not use any port below 1024 because they are reserved for specific tasks
    going above 20 000 can cause problem when you are using low quality hardware such as routers.
    also for FTP if you choose a port ending with 21 that can give a hint that it is a FTP (ex: 1721, 3421 or 7721) so use something like 8349.

    If you want maximum security you can configure SFTP (secure ftp) instead.
    Best regards

Leave a Comment