File Sharing for remote access

In order to give a file access to a remote location, we can not use Samba, we then need to look a bit further. One of the best and most reliable choices is, has been and will be for a little longer, the FTP protocol.

FTP protocol is a client-server organization, we’ll here install the server part. For the client side, you’ll then need to install it on the remote PC from which you want to access your server. For that, I heavily recommend Filezilla for it’s ease of use and portability (available for Windows and Linux).

Install FTP Server

There are, as often, many available solutions, but we are going to use one only. I chose proFTPd for this task. Why? 2 reasons : one is that it is easy to install and configure, second is that there are web interface available for its administration.

To install, connect the server by SSH (or open a terminal window if you are in direct access).

1. Install the proftpd package with MySQL support

apt-get install proftpd-basic proftpd-mod-mysql

2. Edit /etc/proftpd/proftpd.conf by typing

sudo nano /etc/proftpd/proftpd.conf

Then enable the following lines by removing the comment sign (#) or adding the lines to the end of the file.

DefaultRoot ~
Include /etc/proftpd/sql.conf
RequireValidShell off

A quick explanation of these 3 lines :

DefaultRoot ~

We jail the users in their home directory. This is a security settings to avoid your users to have access to the entirety of the disk and potentially mess it up.

Include /etc/proftpd/sql.conf

Call the SQL configuration file where we will tell how proFTPd interact with the database.

RequireValidShell off

we say that basically, we do not need our Linux installation to have the similarly named user.

3. Edit /etc/proftpd/modules.conf by typing :

sudo nano /etc/proftpd/modules.conf

Then enable the following two modules by uncommenting the following 2 lines.

LoadModule mod_sql.c
LoadModule mod_sql_mysql.c

4. Edit /etc/proftpd/sql.conf by typing :

sudo nano /etc/proftpd/sql.conf

Modify the content to get it as below (you can simply remove the content and paste the below one instead). Just amend the root password with the one you choose while installing MySQL server.

SQLBackend mysql
SQLAuthTypes Crypt
SQLConnectInfo proftp_admin@localhost root YourRootPassword
SQLUserInfo usertable userid passwd uid gid homedir shell
SQLGroupInfo grouptable groupname gid members
# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE “count=count+1, lastlogin=now() WHERE userid=’%u'” usertable

So, the server is now installed, or almost installed. We indeed did everything to configure the FTP server to use the MySQL database as user listing but we did not create the database for that. this will actually be done in the second part, when we install the web interface.

Special thanks to the website sysadminworld.com for their tutorial that I used as a base.

Install the web interface

Here, I chose ProFTPd Administrator as it has a complete interface and is simply working perfectly (although some parts of the interface are not working).

First thing first, download the version 1.2 of this package.

Unpack it

Modify the database structure file
There are few things to modify in the extracted folder to make it work.
In the file misc/

  • Replace all TYPE=MyIASM by ENGINE=MyIASM
  • Change the MySQL username and password in the last 3 lines

There is as well a small bug to fix
replace password by ENCRYPT

Create the database

mysql -u root -p < misc/database_structure_mysql/db_structure.sql

Open the interface

configure your database connexion parameters

add users

Restart the server

We did quite a few modifications on the server configuration, so to be taken into account, the server has to be restarted.

Do not restart the full machine (although that would be fine too), just restart the FTP server service by issuing the following command :

sudo service proftpd restart

Follow-up and maintenance

Some more things to know :

  • When adding users through the web interface, no need to restart the FTP server