Add ftp service to your Ubuntu Server

Jack Wallen
Sep 6, 2009
Updated • Nov 30, 2012
Linux
|
8

So you now have your Ubuntu Server up and running with the help of "Installing Ubuntu Server 9.04" and you now have Samba working with the help of "Set up your new Ubuntu Server as a Samba Server". Now it's time to add ftp to the mix. Of course many people are of the mind set that FTP servers are slowly becoming a thing of the past. I would disagree because of the low cost of hardware, ease of set up, and ease of use. You can't beat an FTP server up on your network as a central file repository.

Now that you already have your Ubuntu Server up and running, adding FTP is actually quite easy. There are numerous FTP servers available, but the one I tend to prefer is vsftpd. Not only is it more secure than many other FTP servers, it's easy to install and configure, even for anonymous use.

In this article you will see how to get vsftpd installed and configured for both user login and anonymous use.

Installing vsftpd

Since the installation for the base server is a GUI-less Ubuntu 9.04, the entire installation and configuration will be done from the command line. Log into your server and then issue the following command:

sudo apt-get install vsftpd

The above command will install everything needed for your FTP server. What you will find is your configuration file located in the /etc directory and the executable located in /etc/init.d/. By default vsftpd is installed to allow ONLY anonymous download. The default location for anonymous files is in /home/ftp. So by default all you need to do is place files you want to be accessible anonymously in /home/ftp, start the vsftp daemon with the command:

sudo /etc/init.d/vsftpd start

And you can immediately connect anonymously. Any file located within /home/ftp will be available to anonymous users. That's not a bad setup for an internal LAN. But if you need to control what people use/see, or if you do not want to allow anonymous access, you will have to take care of a little configuration.

Configuring user-authenticated login

Let's say you have four users on your system that need access to their own individual accounts. For this you will need to enable user-authenticated login. This is done within the /etc/vsftpd.conf file. Open up this file and scroll down to around line 26. Here you will see the entry:

#local_enable=YES

Notice the "#" symbol at the beginning of the line? This means that line is commented out. Remove the "#" symbol, save the file, restart vsftpd, and now anyone with an account on your ftp server can log in with their username and password.

But what if the users need to upload as well as download? Simple. Below the local_enable line you will see the line:

#write_enable=YES

Uncomment out that line and restart vsftpd to enable write access for your users. Remember, you have to restart vsftpd any time you make a change to the configuration file. You can also disable anonymous access by commenting out the line:

anonymous_enable=YES

This can be handy for departments as well. Say you have an editorial department, a graphics department, and an accounting department. You will have to have those accounts added to the system. You can add those accounts (and their home directories) with these commands:

sudo useradd -m ACCOUNT_NAME

sudo passwd ACCOUNT_NAME

Where ACCOUNT_NAME is the name of the user account to create. The above commands will create the user, the users' home directory, and give the user a password.

Once these accounts have been created you can log into the FTP server with the username and password.

Final thoughts

Setting up an FTP server couldn't be any easier. With the Ubuntu Server already up and running, you can have anonymous ftp set up in about a minute.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. christopher wilson said on September 23, 2012 at 1:00 am
    Reply

    Hi, Im not sure if this would help you or not but I have written a guide about how you can do this with pureftp on ubuntu server 12.04. You can set up different accounts which you can manage through mysql. As i said, im not sure if this is you wanted but I hope it helps

    http://wilson18.com/how-to/linux-networking/how-to-add-ftp-accounts-for-your-hosted-sites/

  2. blah said on May 12, 2011 at 6:23 pm
    Reply

    what if the file to write in the vsftpd.conf always pops up as write only how do i change this?

  3. Ray said on March 2, 2010 at 7:50 am
    Reply

    What could be the reason the server is letting the user go higher that its own home directory? How to prevent this to happen.

    Thanks!

    1. DarkWulf said on March 8, 2010 at 5:48 pm
      Reply

      Just add

      chroot_local_user=YES

      to /etc/vsftpd.conf
      then users are locked to theyre homedirs.

  4. 127.0.0.1 said on September 6, 2009 at 9:26 am
    Reply

    What if the machine is on dynamic ip?

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.