Skip to content

Instantly share code, notes, and snippets.

@Albonycal
Created March 22, 2021 03:00
Show Gist options
  • Save Albonycal/422d35f26c9d92f8e20e6a964bb3f53a to your computer and use it in GitHub Desktop.
Save Albonycal/422d35f26c9d92f8e20e6a964bb3f53a to your computer and use it in GitHub Desktop.
FTP
Install Pure-FTPd
First, install Pure-FTPd using the following command line in Terminal:
sudo apt install pure-ftpd
Basic Configurations
We need to create a new user group named ftpgroup and a new user named ftpuser for FTP users, and make sure this "user" has no login privilege and no home directory:
sudo groupadd ftpgroup
sudo useradd ftpuser -g ftpgroup -s /sbin/nologin -d /dev/null
FTP Home Directory, Virtual User, and User Group
For instance, make a new directory named FTP for the first user:
sudo mkdir /home/$USER/FTP
Make sure the directory is accessible for ftpuser:
sudo chown -R ftpuser:ftpgroup /home/pi/FTP
Create a virtual user named upload, mapping the virtual user to ftpuser and ftpgroup, setting home directory /home/pi/FTP, and record password of the user in database:
sudo pure-pw useradd upload -u ftpuser -g ftpgroup -d /home/pi/FTP -m
A password of that virtual user will be required after this command line is entered. And next, set up a virtual user database by typing:
sudo pure-pw mkdb
Last but not least, define an authentication method by making a link of file /etc/pure-ftpd/conf/PureDB, the number 60 is only for demonstration, make it as small as necessary:
sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb
Restart the program:
sudo service pure-ftpd restart
Test it with an FTP client, like FileZilla.
More Detailed Configurations:
The configuration of Pure-FTPd is simple and intuitive. The administrator only needs to define the necessary settings by making files with option names, like ChrootEveryone, and typing yes, then storing in the directory /etc/pure-ftpd/conf, if all FTP users are to be locked in their FTP home directory (/home/pi/FTP). Here are some recommended settings:
sudo nano /etc/pure-ftpd/conf/ChrootEveryone
Type yes, and press Ctrl + X, Y, and Enter.
Likewise,
Make a file named NoAnonymous and type yes;
Make a file named AnonymousCantUpload and type yes;
Make a file named AnonymousCanCreateDirs and type no;
Make a file named DisplayDotFiles and type no;
Make a file named DontResolve and type yes;
Make a file named ProhibitDotFilesRead and type yes;
Make a file named ProhibitDotFilesWrite and type yes;
Make a file named FSCharset and typeUTF-8;
...
Restart pure-ftpd again and apply the above settings.
sudo service pure-ftpd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment