HOW TO INSTALL

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.

 

HOW TO CONFIGURE

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 nano or 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:

#write_enable=YES

To this:

write_enable=YES

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:

anonymous_enable=NO

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:

ftp 127.0.0.1

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:

ftp>

If you see that, you know the server is working. You can return to the regular command line with this command:

exit

 

HOW TO MAKE FILES ACCESSIBLE BY THE CLIENT

To make files available to the client, he must first have an account on the server, to do this:

sudo useradd –d /home/foldername [username]

Add password to the username:

sudo passwd [username]

Create the directory you have assigned to the user:

sudo mkdir –p /home/foldername

To make the directory writeable by the user (in case he needs to send or upload files to the server), give the folder the 777 permission:

sudo chmod 777 foldername

Create or copy files in that folder location that you want to access by the user.

 

HOW TO UPLOAD FILES TO THE SERVER 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:

ftp

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:

ftp 192.168.1.100

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:

ftp>

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:

ls

This will display the contents of the remote directory.

To find which remote directory you’re actually in, you can use the pwd command:

pwd

This command stands for “print working directory”, and will display the current working directory.

 

COMMAND FOR GETTING FILES

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:

If single file:

get report.doc

If multiple files:

mget *

or

mget *.*

This will download the file to your local home directory.

 

COMMAND FOR SENDING FILES

To upload files from the FTP server, you will need to use the put command. For instance, to send a file named “file.doc” to the remote working directory:

If single file:

put file.doc

If multiple files:

mput *

or

mput *.*

This will upload the file to your remote directory.

 

That’s all! Hope these might help.

Please feel free to comment if you have some thoughts. Enjoy!

 

 

Basic FTP Server Setup with vsftpd on Ubuntu Server
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *