Skip to content

Commit 56bdf56

Browse files
malsonyXECDesign
authored andcommitted
Update ftp.md
1 parent c8e741a commit 56bdf56

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

remote-access/ftp.md

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,98 @@
11
# FTP
22

3-
FTP (File Transfer Protocol) can be used to transfer files between a Raspberry Pi and another computer
3+
FTP (File Transfer Protocol) can be used to transfer files between a Raspberry Pi and another computer. Although with default program `sftp-server` of Raspbian the users with sufficient privilege can transfer files or directories, access to the filesystem of the limited users is also required oftenly. Follow the steps below to set up an FTP server:
4+
5+
## Install Pure-FTPd
6+
7+
Firstly install `Pure-FTPd` using the following command line in Terminal:
8+
9+
```bash
10+
sudo apt-get install pure-ftpd
11+
```
12+
13+
## Basic Configurations
14+
15+
We need to creat a new user group named `ftpgroup` and a new user named `ftpuser` for FTP users, and make sure this "user" has NO log in privilge and NO home directory:
16+
17+
```bash
18+
groupadd ftpgroup;
19+
useradd ftpuser -g ftpgroup -s /sbin/nologin –d /dev/null
20+
```
21+
22+
### FTP Home Directory, Virtual User, and User Group
23+
24+
For instance, make a new directory named `FTP` for the first user:
25+
26+
```bash
27+
sudo mkdir /home/pi/FTP
28+
```
29+
30+
Make sure the directory is accessable for `ftpuser`:
31+
32+
```bash
33+
sudo chown -R ftpuser:ftpgroup /home/pi/FTP
34+
```
35+
36+
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:
37+
38+
```bash
39+
sudo pure-pw useradd upload -u ftpuser -g ftpgroup -d /home/pi/FTP -m
40+
```
41+
42+
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:
43+
44+
```bash
45+
sudo pure-pw mkdb
46+
```
47+
48+
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:
49+
50+
```bash
51+
ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb
52+
```
53+
54+
Restart the program:
55+
56+
```bash
57+
sudo service pure-ftpd restart
58+
```
59+
60+
Test it with an FTP client, like FileZilla.
61+
62+
## More Detailed Configurations:
63+
64+
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:
65+
66+
```bash
67+
sudo nano /etc/pure-ftpd/conf/ChrootEveryone
68+
```
69+
70+
Type `yes`, and press ``Ctrl+X``, ``Y``, and ``Enter``.
71+
72+
Likewise,
73+
74+
make a file named `NoAnonymous` and type `yes`;
75+
76+
make a file named `AnonymousCantUpload` and type `yes`;
77+
78+
make a file named `AnonymousCanCreateDirs` and type `no`;
79+
80+
make a file named `DisplayDotFiles` and type`no`;
81+
82+
make a file named `DontResolve` and type `yes`;
83+
84+
make a file named `ProhibitDotFilesRead` and type `yes`;
85+
86+
make a file named `ProhibitDotFilesWrite` and type `yes`;
87+
88+
make a file named `FSCharset` and type`UTF-8`;
89+
90+
...
91+
92+
Restart `pure-ftpd` again and apply the above settings.
93+
94+
```bash
95+
sudo service pure-ftpd restart
96+
```
97+
98+
For more information of Pure-FTPd and documentation, please get on official website of [Pure-FTPd](http://www.pureftpd.org/project/pure-ftpd).

0 commit comments

Comments
 (0)