It’s pretty simple to install and to a basic configuration of an FTP server on Ubuntu 11.04 Natty Narwhal. By default Ubuntu uses a package called vsftpd as an FTP server, which is currently the most popular FTP package for Linux systems. To install the vsftpd package, use the following command at the Terminal:
sudo apt-get install vsftpd
Follow the default prompts, and the vsftpd server will be installed on your computer. Generally, the default configuration for vsftpd is pretty secure, and good enough for casual use. Anonymous users are blocked, and no one can write files to the server (or, in FTP terminology, no one can upload files to the server). Anyone with a system account will be able to connect to the FTP server and download, though not upload, files.
If you want to change any settings, the configuration file for vsftpd is /etc/vsftpd.conf. Like any other configuration file, you can edit it with vi:
sudo vi /etc/vsftpd.conf
(If you’re using the desktop version of Ubuntu, you can of course use the graphical gedit editor.)
The vsftpd.conf file contains a large number of “directives” that govern how the server behaves and operates. If you want to change its configuration, you’ll need to alter the directives.
If you want users to be able to write files to your FTP server, change this directive:
With the write_enable directive set to YES, users will be able to upload files to your FTP server. Note, however, that they will only be able to do so if they have proper permissions to the directories in question. They’ll be able to upload files to their home directories, but not, for instance /var or /usr.
Anonymous access is controlled with this directive:
Under no circumstances should you allow anonymous access to your FTP server, especially if it is accessible from the Internet! There are certain circumstances when you might find it useful, but you should only enable it if you know exactly what you are doing. Generally, it is almost always best to keep anonymous_enable set to NO.
If you make any changes to the file, switch vi to command mode, save the changes, and then exit vi. Then restart the vsftpd server so it reads its new directives:
sudo service vsftpd restart
You can then test your Ubuntu machine’s FTP service from the server’s command line:
The FTP client will ask for your username. Enter that, and then the client will ask for your password. Enter that as well, and you should then see the FTP prompt, which looks like this:
If you see that, you know the server is working. You can return to the regular command line with this command:
USING THE FTP CLIENT
Just because you have an FTP server doesn’t mean you can access it straightaway – you first need a program called an “FTP client” that will let you communicate with the FTP server. Fortunately, Ubuntu comes with a built-in FTP client – you can access it from the command line by simply typing:
However, it’s far easier to use if you know the IP address of the FTP server you want to access. Let’s say you want to access a FTP server with an IP address of 192.168.1.100. To do so, you would append the IP address to the ftp client command:
The FTP client will then ask for your username. (Note that this will be your username and password on the FTP server, not the computer with the FTP client.) Type it and hit enter. The client will ask for your password, which you should then enter. Once you do, you’ll be taken to the FTP prompt, which looks like this:
You can also specify a different username as part of the ftp command. If, for instance, you wanted to use our camalas account to connect to the FTP server at 192.168.1.100, the command would look like this:
Once at the FTP prompt, you can use some of the common terminal commands. To see a listing of the remote directory, you can use the reliable ls command:
This will display the contents of the remote directory.
To find which remote directory you’re actually in, you can use the pwd command:
This command stands for “print working directory”, and will display the current working directory.
To download files from the FTP server, you will need to use the get command. For instance, to retrieve a file named “report.doc” from the current working directory:
This will download the file to your local home directory.