Basic installation and use of pureftpd under Linux and solution of timeout problem

Time:2020-11-22

Basic installation and use method

Before installation, it is better to use netstat – NTL to check whether the default port 21 of FTP is occupied. At the same time, you can also use the PS – EF command to check which services are opened and whether there are services similar to SFTP or vsftp. If enabled, use the kill SFTP command to kill the service
1. Download pureftp, I downloaded pure-ftpd-1.0.30
Instructions:

Copy code

The code is as follows:

wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.30.tar.bz2

2. Decompression:

Copy code

The code is as follows:

tar -xvjf pure-ftpd-1.0.30.tar.bz2

Enter the directory after decompression:

Copy code

The code is as follows:

cd pure-ftpd-1.0.30

3. Compile mode, all installations are recommended

Copy code

The code is as follows:

./configure –prefix=/usr/local/pure-ftpd/ –with-
language=simplified-chinese –with-everything

4. Installation:

Copy code

The code is as follows:

make && make check && make install

Establish the corresponding installation directory

Copy code

The code is as follows:

mkdir /usr/local/pure-ftpd/etc

6. Copy the configuration file and main execution file to the corresponding folder:

Copy code

The code is as follows:

cp configuration-file/pure-ftpd.conf /usr/local/pure-ftpd/etc/
cp configuration-file/pure-config.pl /usr/local/pure-ftpd/sbin/
chmod 755 /usr/local/pure-ftpd/sbin/pure-config.pl

 
7. Customize the following system environment variables:

Copy code

The code is as follows:

cd /usr/local/bin/
ln -s /usr/local/pure-ftpd/bin/* .
ln -s /usr/local/pure-ftpd/sbin/* /usr/local/sbin/
ln -s /usr/local/pure-ftpd/man/man8/* /usr/local/share/man/man8/

8. Start pureftp server:

Copy code

The code is as follows:

pure-config.pl /usr/local/pure-ftpd/etc/pure-ftpd.conf

The following information is generally displayed on the screen:
Running: /usr/local/pure-ftpd/sbin/pure-ftpd -A -b -B -C20 -d -e -fnone -H -I15 -L2000:8 -M -m4 -p45000:50000 -q1:10 -s -t200 -U133:022 -u100 -r -Oclf:/var/log/pureftpd.log -k99 -Z
At this time, you can use the telnet IP address 21 in the command line window to detect whether the port is connected
9. Pureftp generally needs to operate without the default root user. Generally, it will create a user name and group and log in with a virtual user
Create group:

Copy code

The code is as follows:

groupadd ftpgroup

Create user:

Copy code

The code is as follows:

useradd -g ftpgroup -d /dev/null -s /etc ftpuser

After creation, you can use cat / etc / passwd and cat / etc / group to check whether the group and user have been created
10. Add FTP virtual user

Copy code

The code is as follows:

ure-pw useradd test -u ftpuser -d /home/ftpusers/test

If you want to delete it after adding, you can use the pure PW userdel test command
To change the password, use the pure PW passwd test command
11. View user information

Copy code

The code is as follows:

pure-pw show test

12. Generate database file

Copy code

The code is as follows:

pure-pw mkdb

13. Pay attention to modifying the configuration file, because the default installation location of many configuration file databases is not the actual location, which will cause each login
You can’t find the password in Lu. FTP always displays passwd required, so you must modify the configuration file after installation, especially the pink one
Parts, pay attention to modification
Open profile:

Copy code

The code is as follows:

vi /usr/local/pure-ftpd/etc/pure-ftpd.conf

 
Chroot everyone yes ා enable chroot
Broken clients compatibility yes
Daemonize yes ා running in the background
Maxclientsperip 20 # maximum connections per IP
Verboselog yes
Displaydotfiles “no”
Anonymousonly “no”
Noanonymous yes ා anonymous users are not allowed to connect
Syslogfacility none ා does not display logs in syslog logs
Dontresolve yes
MaxIdleTime 15 ා maximum idle time
Limitrecursion 2000 8 – browse restrictions, file 2000, directory level 8
Anonymous can create dirs no ා anonymous users can create directories
Maxload 4 ා disable downloading after exceeding load
Passiveportrange 45000 50000 ᦇ passive mode port range
#Anonymous ratio 1 10
Userratio 1 10 ා upload / download ratio of all users
Anti warez yes ා prohibit downloading files uploaded by anonymous users but not verified
#Anonymous bandwidth 200 ා anonymous user bandwidth limit (KB)
Userbandwidth 8 ා maximum bandwidth of all users (KB)
Umask 133:022 ා create file / directory default mask
Miniuid 100 ා maximum uid limit
Allowuserfxp no ා only run the user for FXP transmission
Allowanonymousfxp no ා allows anonymous FXP transmission for anonymous and non anonymous users
Prohibitdotfileswrite no ා hidden files cannot be deleted / written
Prohibitdotfilesread no
Autorename yes ා automatically rename a file with the same name
Do not allow anonymous upload
AltLog                     clf:/var/log/ pureftpd.log CLF format log file location
PureDB                     /usr/local/pure-ftpd/etc/ pureftpd.pdb User database file
Maxdiskusage 99 ා when the disk usage reaches 99%, upload is prohibited
Createhomedir yes ා automatically created if the virtual user’s directory does not exist
Customerpoof yes ා prevent command misoperation
 
PureDB                     /usr/local/pure-ftpd/etc/ pureftpd.pdb This place must remember to modify, otherwise it will always be
Unable to log in. You can execute it again after modification
14. Regenerate the database file

Copy code

The code is as follows:

pure-pw mkdb

15. Kill the previous pureftp service

Copy code

The code is as follows:

killall pure-ftpd

16. Then restart

Copy code

The code is as follows:

/usr/local/pure-ftpd/sbin/pure-config.pl /usr/local/pure-ftpd/etc/pure-ftpd.conf

17. At this time, you can login successfully, but you may still be unable to upload to the server. At this time, it is generally a problem of permissions,
Log in to FTP’s home directory

Copy code

The code is as follows:

cd /home/ftpusers/test

Modify the file permissions under the test folder

Copy code

The code is as follows:

chown ftpuser:ftpgroup wenjian1

Try to connect again and upload later.

Record of solving the problem of connection timeout
problem
Recently, pureftpd has been installed on the server to upload files to colleagues in the company. There is no problem using FileZilla to test before delivery, but colleagues reflect that FTP cannot be used under Linux.
I tested it under Linux, stuck in enter passive mode all the time, and finally timed out.
20151120105747371.png (401×112)

reason

There is no problem using FileZilla in windows. After a close look at FileZilla’s log, there is a line
20151120105807655.png (400×103)

It is thought that pureftpd uses virtual machine, and the network card of virtual machine is only bound with internal network IP, and external network ip should be bound in routing. It is speculated that when FTP clients connect to pureftpd in passive mode, pureftpd returns an intranet IP.
Through Wireshark, we found that:
20151120105825199.png (548×127)

You can see that the server did return an intranet address.
method
Can we force pureftpd to return to the Internet IP. By looking at the pureftpd document, we found that the pureftpd.conf Add:

Copy code

The code is as follows:

ForcePassiveIP 1.1.1.1

1.1.1.1 is the extranet IP of pureftpd. After the restart, the problem is solved.