In this tutorial, we will see how to install an FTP server on our Linux VPS. The tutorial is Debian and Ubuntu compatible.
All the following commands must be executed with the root user.
Installation of the package
The installation of proftpd requires only a simple command through the package manager:
apt install proftpd-basic
Configuration
The default configuration is valid, nevertheless it is necessary to check several points in the file /etc/proftpd/proftpd.conf
:
First of all, you have to make sure that the users are chrooted in their user directory, so that they can't walk around on the whole system, with the option :
DefaultRoot ~
Second, setting up passive ports can allow customers having problematic routers to use ports that are usually well unlocked on the way out:
PassivePorts 60000 65534
Virtual user management
By default, authentication is done with Unix users only (= system users).
It is advisable to set the authentication by virtual users, for a more flexible management. In the /etc/proftpd/proftpd.conf
, check that these lines are not commented. If they are not present, add them.
AuthUserFile /etc/proftpd/ftpd.passwd
AuthOrder mod_auth_file.c
Then check that the value RequireValidShell = off
is well present, and not commented.
We will now initialize the file ftpd.passwd
which proftpd will then use to store the information of FTP users.
touch /etc/proftpd/ftpd.passwd
chmod 440 /etc/proftpd/ftpd.passwd
The configuration is finished, you just have to restart the proftpd service:
service proftpd restart
Add users
The addition of an FTP user is done with the following command.
Replace
-
LOGIN
by the username of the FTP account (ex: jdoe). -
UID
by the UID of the system user account to which the FTP account belongs (to find the UID of a linux account,id nomdeluser
, for exampleid root
). -
GID
by GID of the group of the system user account to which the FTP account belongs (to find the GID of a linux account,id nomdeluser
, for exampleid root
). -
/PATH/TO/HOME
by the path of the directory to which the FTP account will have access.
To learn more about how to retrieve a user's UID and GID, see the following tutorial: [How to find a user's UID or GID(https://mtxserv.com/vps-server/doc/how-to-find-the-uid-or-gid-of-a-linux-user).
ftpasswd --passwd --file=/etc/proftpd/ftpd.passwd --name=LOGIN --uid=UID --gid=GID --home=/PATH/TO/HOME --shell=/bin/false
To avoid prompting for the password, you can use the --stdin
option as follows:
echo "PASSWORD" | ftpasswd --passwd --stdin --file=/etc/proftpd/ftpd.passwd --name=LOGIN --uid=UID --gid=GID --home=/PATH/TO/HOME --shell=/bin/false
Change user password
The modification is done by the following command:
ftpasswd --passwd --file=/etc/proftpd/ftpd.passwd --change-password --name=LOGIN
To avoid prompting the password, you can use the --stdin
as follows:
echo "MOTDEPASSE" | ftpasswd --passwd --file=/etc/proftpd/ftpd.passwd --change-password --name=LOGIN --stdin
Deleting a user
To delete a user, use the following command:
ftpasswd --passwd --file=/etc/proftpd/ftpd.passwd --delete-user --name=LOGIN
Shell verification bug
In case of invalid shell problem related to the use of user there are 2 possible solutions.
- Either disable shell checking:
RequireValidShell off
- Either add to the file
/etc/shells
:/bin/false
For the sake of cleanliness, prefer the second solution :-)