Configuring FTP server in Ubuntu 14.04

14018860-server-icon-hosting-server              Configuring FTP server is mainstream process, this is how my statement would be if I  configured FTP service in any OS, other than Ubuntu 14.04.1 🙂

To set up this blog, I installed LAMP stack followed by WordPress installation and everything went mainstream without any errors.

I decided to install one of the wordpress themes to my blog (this blog) and this decision was the root cause for me to write this post on FTP server installation in Ubuntu 14.04.1.

Yes, setting up FTP server in Ubuntu 14.04 needs some extra configurations to be included in the FTP configuration file.

So here comes the steps to be followed for installing FTP server in Ubuntu 14.04, especially for wordpress theme lovers 🙂

Step 1: Install vsftpd

Warning: FTP data is insecure, traffic is not encrypted and all the transmissions are clear text (including user names, passwords, commands, and data). So securing your FTP connection with SSL/TLS is necessary.

Install VsFTPD package using the below command.

$apt-get update

$apt-get -y install vsftpd

Step 2: Configure vsftpd

Let’s edit the configuration file for vsftpd:

Make a backup copy of the config file just in case

$sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.backup

$vim /etc/vsftpd.conf

Disallow anonymous, unidentified users to access files via FTP; change the anonymous_enable setting to NO:

anonymous_enable=NO

Allow local users to login by changing the local_enable setting to YES:

local_enable=YES

If you want local user to be able to write to a directory, then change the write_enable setting to YES:

write_enable=YES

Local users will be ‘chroot jailed’ and they will be denied access to any other part of the server; change the chroot_local_user setting to YES:

chroot_local_user=YES

Add the following lines to enable passive mode at the end of the /etc/vsftpd.conf file

pasv_enable=YESpasv_min_port=13000pasv_max_port=13100port_enable=YESpasv_address=[public dns of your web server. In my case, vinoth6664.com]pasv_addr_resolve=YES

Exit and save the file with the command :wq .

Restart the vsftpd service:

$service vsftpd restart

Step 3: Configure the User’s Home Directory:

By default, FTP will take user’s home directory as it’s root directory. But in our case for the configuring FTP user to install wordpress theme, we should set the root directory as /var/www/html.

    For that, we are going to create dedicated user for FTP.

        $sudo adduser ftpuser2

        $sudo passwd ftpuser2

        $sudo usermod -d /var/www/html ftpuser2

With certain version of vsftpd you may receive the following error: 500 OOPS: vsftpd: refusing to run with writable root inside chroot().

Not to worry! Create a new directory for the user receiving the error(ftpuser2 in this case) that is a subdirectory of their home directory (/home/ftpuser2). For example:

Fix permissions for ftpuser2‘s home directory:

$chmod a-w /home/ftpuser2/

$mkdir /home/ftpuser2/upload

$chown user2:user2 /home/ftpuser2/upload/

Step4: Iptables configuration.

You need to open the following ports,

TCP Ports 13000 – 13100 ( ftp data bind with any port range from 13000-13100)TCP Ports 20 – 21

Use the following Iptables commands to open the ports

$iptables -A INPUT -p tcp –match multiport –dports 20:21 -j ACCEPT

$iptables -A INPUT -p tcp –match multiport –dports 13000:13100 -j ACCEPT

Step 5: Set to go.

Restart the vsftpd service. Then open ftp://<ip-address-web-server>.

Now you can use the ftpuser2 credentials in wordpress to install themes.

 

Cheers,

Vinoth6664

Leave a Comment