vsFTPd, ProFTPD and PureFTPd are great choices for an FTP server that all work well. Each has a GUI applications available to help manage settings. However PureFTPd is lightweight, supports MLST/MLSD, supports virtual folders using symbolic links (symlinks) and supports the SITE UTIME command required to synchronize file date/time stamps when you transfer them. It is therefore the FTP server that typically I recommend on Linux.
Installing Pure-FTPd
To install PureFTPd in Ubuntu (and probably most Debian based releases), execute the following command and a terminal/shell prompt:
sudo apt-get install pure-ftpd
By the way, if for any reason you mess-up the Pure-FTPD installation and want to start over, you can uninstall it completely using all of the following set of commands:
sudo service pure-ftpd stop
sudo apt-get autoremove pure-ftpd
sudo apt-get purge pure-ftpd
sudo rm -r /etc/pure-ftpd
Unlike most FTP servers, Pure-FTPd has almost no configuration files. It is all command-line driven.
If you plan on using virtual users on your ftp-server instead of regular Linux user accounts, start by creating an unprivileged user and group that is dedicated to those users using the following commands:
sudo groupadd ftpgroup
sudo useradd -g ftpgroup -d /dev/null -s /etc ftpuser
sudo chown -R ftpuser:ftpgroup /home/ftpuser
This will also create a shared space called ftpuser. This will be the root of their access on the server if you create your users in chroot jail where they can't move up to higher levels. Of course you can alternatively create individual directories for each user instead if you don't want them to have shared space and then optionally link them to a specially setup shared area using a symlink. We'll get to the topic of symlinks shortly.
The ftpgroup group and the ftpuser user will be needed when you are setting up users in your ftp server.
Managing Pure-FTP Virtual Users
Managing users from the command line is pretty simple. Note that Pure-FTPd users can alternatively be managed using a MySQL database. That topic is not covered here but should be considered if you want to optimize management of thousands of ftp users on your sever.
Here are the commands (you can script them) to manage your users. Be sure to replace $USERNAME with the actual user id of the individual user.
Creating the First User
sudo pure-pw useradd $USERNAME -u ftpuser -d /home/ftpuser
sudo pure-pw mkdb
… if creating an admin user with full access to the server, omit the -d /home/ftpuser parameter which would normally causes this directory to become the root of the users ftp session.
Creating Additional Users
In chroot jail:
sudo pure-pw useradd $USERNAME -u ftpuser -d /home/ftpuser -m
Not in chroot jail:
sudo pure-pw useradd $USERNAME -u ftpuser -D /home/$USERNAME -m
View a User
sudo pure-pw show $USERNAME
Change a User's Password
sudo pure-pw passwd $USERNAME -m
Update an Existing User
See Pure-FTPd documentation for a list of options to replace $OPTIONS.
sudo pure-pw usermod $USERNAME $OPTIONS -m
Deleting a User
sudo pure-pw userdel $USERNAME -m
Listing All Users
sudo pure-pw list
Update the User/Password Database Manually
(in case you forgot the -m)
sudo pure-pw mkdb
Managing the Pure-FTP Server
Start Pure-FTPd Server
sudo service pure-ftpd start
Stop Pure-FTPD
Note: This does not disconnect active users.
sudo service pure-ftpd stop
Disconnect All Active Users Immediately
sudo killall pure-ftpd
Pure-FTPd Status
sudo service pure-ftpd status
Restart Pure-FTPd
sudo service pure-ftpd restart
View Server Activity
sudo pure-ftpwho
Changing the Welcome Message
This message is only visible to command line users and in some FTP clients. To see what your server currently displays, open a command prompt and type:
In order to customize or even remove this message, you must create a FortunesFile file:
sudo echo "/home/ftpuser/fortunes.txt" > /etc/pure-ftpd/conf/FortunesFile
In the fortunes.txt file, put any message you want to display or leave it empty.
Setting Pure-FTPd to Start-up When the Server Restarts
Important: You must do the following or the server will not recognize virtual users after you restart the server:
cd /etc/pure-ftpd.conf
sudo echo 'no' > PAMAuthentication
sudo echo 'no' > UnixAuthentication
sudo echo '/etc/pure-ftpd/pureftpd.pdb' > PureDB
sudo ln -s ../conf/PureDB /etc/pure-ftpd/auth/50pure
Virtual Directories
Pure-FTPd supports virtual symbolic links (a.k.a. symlinks) to directories in other palces on the server -- outside your home directory. For example, you can create one using the following commands:
Create a symlinks to each of the different areas on the server that they will need access to:
ln -s /var/www /home/ftpuser/www
To remove a symbolic link, simply delete it. Example:
rm /home/ftpuser/www
This will only delete the symbolic link and not the contents of the folder. Just be sure it is a symbolic link and not a mounded directory though.
If you have any trouble making changes to files on your Apache server, try adding www-data to the ftpgroup group.
February 27, 2014 at 9:09 AM
I have been finding the whole Google for this type of tutorials. This is one of best tut about PureFTPd. I was gone crazy trying to setup the FTP Server because I’m a linux noob. Thanks a lot! It works like charm now!
February 28, 2014 at 12:55 AM
Thank you for your very kind words. Glad to hear you found it useful Areeb.
Best regards,
Michael
October 10, 2014 at 2:11 PM
This is by far the best tutorial to get the pure-ftpd server up and running on internet. Thanks a lot man.. keep up the good work.
January 12, 2015 at 6:52 AM
Hi, if I try the command
sudo pure-pw useradd $USERNAME -u ftpuser -d /home/ftpuser
I get the following error:
/usr/local/bin/pure-pw: 1: /usr/local/bin/pure-pw: Syntax error: word unexpected (expecting “)”)
For “$USERNAME” I substituted “1002”, which ist the ID I got from
id -u ftpuser
Is this correct?
Can you maybe help me?
June 8, 2015 at 1:29 PM
This indeed is a great article which explains the various concepts involved very clearly.
Thanks for the good work done !
I need a small clarification – whether the protocol used in this will be ftp or sftp ?
I need to setup a server specifically using sftp as protocol.
Thanking in Advance
July 28, 2015 at 11:55 PM
Thanks for the great question Rajesh. The above instructions result in the implementation of an FTP server. If you want to use sftp, you need to implement ssh on your server. In Ubuntu, the easiest way to do this is to install OpenSSH. I have not written up any instructions on how to do this yet but you might find the following link helpful:
http://askubuntu.com/questions/420652/how-to-setup-a-restricted-sftp-server-on-ubuntu
Best regards,
Michael Milette
November 7, 2016 at 3:10 AM
Hi, I succeed to create the user, pass and everything, updated the DB but I still cannot connect… Response: 530 Login authentication failed
Any ideas?
November 16, 2016 at 4:43 PM
Hi GBG,
Sorry to hear that it isn’t working for you. Unfortunately the details you provided are insufficient for me to determine the cause of your issue. Resolving the issue would require troubleshooting of your system’s configuration in order to identify the cause. Please feel free to contact me in order to arrange for my services.
Best regards,
Michael Milette
May 12, 2017 at 10:29 AM
About “This will also create a shared space called ftpuser.”, actually these commands don’t create anything on Debian, you have to add the “-m” option to useradd.
June 29, 2017 at 10:46 AM
I just wanted to let you know that you are an absolute life saver.
Ive been trying to get an FTP server using virtual users set up for a few days now (Normally I work exclusively with windows where its a 10 minute job!), this is by far the easiest tutorial to follow, just enough tech detail so we know whats going on without so mush that its overwhelming for a linux newbie.
My only comment is that when creating the users and doing the chown on the home directory, the directory had not been created at that point so I had to do a MKDIR and create the home directory /home/ftpuser before doing the chown on it.
Also when doing the steps in “Setting Pure-FTD to start-up when the server restarts” it all makes sense, just creating files with “no” in them.. until the last line ln -s ../conf/PureDB /etc/pure-ftp/auth/50pure
I genuinely have not idea what that did, but it works 🙂
September 19, 2017 at 3:33 PM
Hi David, thank you for taking the time to write. I always love hearing from people.
Glad to hear that the information helped. I am grateful that you pointed out ways to improve accuracy of the article.
That’s why I write them! Thanks again. 🙂
Best regards,
Michael
September 6, 2017 at 6:11 PM
Hi I have followed all steps but I cannot get virtual users to authenticate. I keep getting login authtication failed.
Can anyone help me?
November 27, 2017 at 4:56 AM
May I know how to add pure-ftpd user to multiple groups, Thanks in advance.