Pure-ftpd
Installing pure-ftpd
There are many open-source ftp server solutions out there, but this guide focuses on pure-ftp due to its integration with mySQL and apache.
$ sudo emerge -av pure-ftpd
after the daemon has been installed, you need to configure it.
$ sudo nano -w /etc/conf.d/pure-ftpd
Uncomment the configuration flag
IS_CONFIGURED="yes"
Configure ssl support
MISC_OTHER="-A '-Y 1' -j -R -Z"
Add the MySQL authenticator at the end of the file
AUTH="-l mysql:/etc/pureftpd-mysql.conf"
Now we will configure ssl support.
$ sudo mkdir -p /etc/ssl/private $ sudo openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
Answer the questions asked. Once it is done
$ sudo chmod 600 /etc/ssl/private/pure-ftpd.pem
Next, we'll download a user manager for pureftpd
$ cd /var/www/localhost/htdocs $ sudo wget http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz
Next we extract the file. Change the filename if you download a more recent file.
$ sudo tar zxf ftp_v2.1.tar.gz
Once the files have extracted, we need to set permissions so that they work correctly
$ sudo chown -R apache:apache ftp $ sudo chmod 664 ftp/config.php
To start the ftp setup wizard, open a browser and go to http://localhost/ftp/install.php. Go through the installation as you see fit. Be sure to change the default password from tmppasswd to something else. When you reach the final step, copy and paste the contents of the generated pureftpd-mysql.conf file, and create it.
$ sudo nano /etc/pureftpd-mysql.conf
(copy and paste the file contents and save the file) Once you are done, close the installation wizard. you may find the 16 char limit for user names annoying. To change this, log into mysql as root
$ mysql -u root -p
Change to the ftpusers database, modify the users table, then exit mysql.
mysql> use ftpusers; mysql> alter table users modify User varchar(32); mysql> quit
Next we will try to start the ftp server
$ sudo /etc/init.d/pure-ftpd start
Add the ftp service to startup
$ sudo rc-update add pure-ftpd default
If all has gone well, we just need to delete the user manager tarball
$ sudo rm /var/www/localhost/htdocs/ftp_v2.1.tar.gz
And don't forget the rename the publicly accessible installation file (wow!)
$ sudo mv /var/www/localhost/htdocs/ftp/install.php /var/www/localhost/htdocs/ftp/install.txt