A picture of a coder

Setup FTP Server on Ubuntu Linux Server

A File Transfer Protocol (FTP) server allows users to upload and download files to a server using the FTP protocol. FTP is useful because it is cross platform and faster than HTTP for large files. It also allows a far wider range of transfer commands, including batch transfers and transfers optimized for either ASCII or binary files.

Ubuntu is a very popular distribution of the Linux operating system. Ubuntu is available as either a desktop or server distribution. The steps below provide a guidance to install FTP server on Linux(Ubuntu)

Install vsftpd. Vsftpd is the daemon, or server, that users will connect to. To install vsftpd, from terminal, run the following command

sudo apt-get install vsftpd

vsftpd – FTP Server Configuration.

You can edit the vsftpd configuration file, /etc/vsftpd.conf, to change the default settings. By default only anonymous FTP is allowed. If you wish to disable this option, you should change the following line:

anonymous_enable=YES to anonymous_enable=NO

By default, local system users are not allowed to login to FTP server. To change this setting, you should uncomment the following line:

#local_enable=YES

By default, users are allowed to download files from FTP server. They are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line:

#write_enable=YES

Similarly, by default, the anonymous users are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line:

#anon_upload_enable=YES

The configuration file consists of many configuration parameters. The information about each parameter is available in the configuration file. Alternatively, you can refer to the man page, man vsftpd.conf for details of each parameter.

Once you configure vsftpd you can start the daemon. You can run following command to run the vsftpd daemon:

sudo /etc/init.d/vsftpd start

Create a user group and shared directory. In this case, use /home/ftp-users and a user group name of ftp-users for the remote users

groupadd ftp-users mkdir /home/ftp-docs

Make the directory accessible to the ftp-users group.

chmod 750 /home/ftp-docs chown root:ftp-users /home/ftp-docs

Add users, and make their default directory /home/ftp-docs .

useradd -g ftp-users -d /home/ftp-docs user1 useradd -g ftp-users -d /home/ftp-docs user2 passwd user1 passwd user2

Copy files to be downloaded by your users into the /home/ftp-docs directory.

Change the permissions of the files in the /home/ftp-docs directory for read only access by the group.

chown root:ftp-users /home/ftp-docs/_ chmod 740 /home/ftp-docs/_

Now you must restart the daemon. You can run following command to run the vsftpd daemon:

sudo /etc/init.d/vsftpd restart sudo /etc/init.d/vsftpd restart

Users should now be able to log in via FTP to the server using their new usernames and passwords. If you absolutely don’t want any FTP users to be able to write to any directory, then you should set the write_enable line in your vsftpd.conf file to no: Here is a simple test procedure you can use to make sure everything is working correctly. Check for the presence of a test file on the ftp client server. ll total 1 -rw-r–r– 1 root root 0 Jan 4 09:08 testfile

Connect to bigboy via FTP.

ftp 192.168.1.10

Connected to 192.168.1.100 (192.168.1.100) 220 ready, dude (vsFTPd 1.1.0: beat me, break me)

Name (192.168.1.100:root): user1

331 Please specify the password.

Password:

230 Login successful. Have fun. Remote system type is UNIX. Using binary mode to transfer files.

ftp>