All about FTP users
Does a supplier only support FTP, or do you need to give someone access to one directory instead of a whole home directory?
This article describes what an FTP user is, why FTP is a poor choice for everything else, and how to create one.
What an FTP user is
An FTP user is an extra login that reaches the files of a UNIX user over FTP. It has its own username and password, separate from the UNIX user's, and it can be limited to one directory.
- It can only be used for FTP. An FTP user can't log in over SSH or SFTP, and can't run commands.
- Files uploaded through it are owned by the UNIX user, the same as files uploaded over SFTP. Your website keeps working with them, and permissions stay correct.
- It can't leave its directory. Whatever you set as the directory becomes the top of the tree for that login: the client can't move up to the parent directory, and can't see anything outside it.
- One UNIX user can have several FTP users, each pointing at a different directory.
Avoid FTP where you can
FTP has no encryption. The username, the password, and the contents of every file travel over the network as readable text.
Anyone who can see that traffic can read all of it. That includes other people on the same Wi-Fi network as the person connecting, and every network operator the connection passes through. Once someone has read the password, they can log in as that FTP user themselves and upload files, for example a PHP script that gives them control over your site.
For uploading files, use SFTP instead. SFTP does the same job over an encrypted SSH connection, uses the UNIX user's own username and password (or an SSH key), and needs no extra setup. See All about UNIX users.
There are two situations where an FTP user is still the answer:
- A supplier requires FTP. This is still common in e-commerce, for example a wholesaler that drops a stock or price file on your server every night, or picks up an order export. If their system only speaks FTP, you can't change that from your side.
- Someone needs access to one directory only. A UNIX user logging in over SFTP always gets the entire home directory, including the website's code and configuration files. An FTP user can be pointed at a single subdirectory, so a freelancer or an external system can upload to
uploads/without being able to read or change anything else. FTP users are the only way to do this on a cluster.
If you have to use FTP, limit the damage a leaked password can do:
- Restrict who can connect. Only allow the IP addresses of the supplier or person that needs the access, using a firewall group. See Opening the FTP port below.
- Give the FTP user its own subdirectory rather than the whole home directory.
- Use a unique password. Don't reuse the UNIX user's password, because that password also works for SSH and SFTP.
- Delete the FTP user once the supplier or person no longer needs it.
Requirement: the ProFTPD node group
FTP only works when a node in the cluster has the 'ProFTPD' node group. Until then, the 'FTP' tab described below isn't shown on the UNIX user page at all.
To add the group, see Add a node group.
Use a node with the 'Admin' group
Add 'ProFTPD' to a node that also has the 'Admin' group. Only those nodes are directly connected to the internet, so an FTP server on any other node can't be reached by the supplier or person connecting, even with a firewall rule in place.
The web-based file manager in Core uses FTP as well, so it needs the same node group. Without it, the 'File Manager' tile on the UNIX user's 'SFTP & SSH' tab is greyed out, with a tooltip saying the cluster has no node with ProFTPD. The file manager creates its own temporary login that expires after an hour; you don't need to create an FTP user for it.
Creating an FTP user
FTP users live on the UNIX user page.
Directly
- Navigate to 'Advanced' > 'UNIX Users'.
- Select the UNIX user.
- Navigate to 'FTP'.
Via the project
- Navigate to 'Projects'.
- Select the project.
- Navigate to 'Advanced'.
- Under the 'UNIX User' tile, click 'Manage'.
- Navigate to 'FTP'.
Then click '+' next to 'FTP Users' and fill in:
- 'Username': lowercase letters, digits, dash, underscore, dot and
@. Max 32 characters. It doesn't have to relate to the UNIX user's name. - 'Password': at least 24 characters. The 'Generate' button produces one for you. Copy the password before creating the FTP user: it isn't shown again afterwards, and there's no way to look it up later.
- 'Directory': a path relative to the UNIX user's home directory, for example
uploads. The home directory is shown in front of the field. Leave it empty to give access to the entire home directory.
Click 'Create'. The FTP user appears in the table, and is set up on the cluster shortly after.
The directory has to exist
The cluster doesn't create the directory for you. If it doesn't exist yet, create it first over SFTP or SSH, otherwise logging in over FTP fails.
Connecting
The 'FTP' tab shows what the person connecting needs:
- 'Hostname': one tile per node with the 'ProFTPD' group. Use the hostname shown there.
- 'Port': 21.
Together with the username and password you set, that's the full set of connection details. Any FTP client works, for example FileZilla or WinSCP.
Opening the FTP port
Port 21 is closed to the internet by default. To let anyone connect, add a firewall rule on the node:
- Navigate to 'Servers' > 'Nodes'.
- Select the node with the 'ProFTPD' group.
- Scroll to 'Firewall Rules' and click '+'.
- 'Source': pick a firewall group containing the IP addresses of the supplier or person that needs access. Only pick 'All' if the addresses can't be known in advance — that lets anyone on the internet reach the FTP server and try passwords against it.
- 'Target': 'ProFTPD'.
The 'ProFTPD' target covers port 21 and the passive (PASV) data ports FTP clients negotiate for file transfers. You don't need a second rule for those.
Changing or deleting an FTP user
The password and the directory can't be changed after creation in Core. To change either, delete the FTP user and create a new one.
To delete: on the 'FTP' tab, click 'Delete' on the row and confirm. This removes the login only. The files in the directory are left untouched.
Related concepts
- All about UNIX users: the account an FTP user belongs to, and the SFTP and SSH access that's preferable in almost every case.
- All about firewall rules: the rule that opens port 21, and the firewall groups that limit who may connect.
- Add a node group: how to add the 'ProFTPD' group to a node.