Build common services pure-ftpd services
1. Install pureftp
# cd / usr/local/src/
# wget https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.42.tar.bz2
two。 Install pure-ftpd
# tar-jxvf pure-ftpd-1.0.42.tar.bz2
# cd pure-ftpd-1.0.42
#. / configure-prefix=/usr/local/pure-ftpd-without-inetd-with-altlog-with-puredb-with-throttling-with-peruserlimits-with-tls
# echo $?
# make
# make install
3. Configure pure-ftpd
# cd configuration-file
# mkdir-pv / usr/local/pure-ftpd/etc
# cp pure-ftpd.conf / usr/local/pure-ftpd/etc/pure-ftpd.conf / / configuration file
# cp pure-config.pl / usr/local/pure-ftpd/sbin/pure-config.pl / / Startup File
# chmod 755 / usr/local/pure-ftpd/sbin/pure-config.pl / / modify permissions
You need to modify the configuration file pure-ftpd.conf before starting pure-ftpd
The configuration file is as follows:
ChrootEveryone yes
BrokenClientsCompatibility no
MaxClientsNumber 50
MaxClientsCompatibility 50
Daemonize yes
MaxClientsPerIP 8
VerboseLog no
DisplayDotFiles yes
AnonymousOnly no
NoAnonymous no
SyslogFacility ftp
DontResolve yes
MaxIdleTime 15
PureDB / usr/local/pure-ftpd/etc/pureftpd.pdb
LimitRecursion 3136.8
AnonymousCanCreateDirs no
MaxLoad 4
AntiWarez yes
Umask 133:022
MinUID 100
AllowUserFXP no
AllowAnonymousFXP no
ProhibitDotFilesWrite no
ProhibitDotFilesRead no
AutoRename no
AnonymousCantUpload no
PIDFile / usr/local/pure-ftpd/var/run/pure-ftpd.pid
MaxDiskUsage 99
CustomerProof yes
Don't make a mistake in the configuration. I typed it myself before, so there were some typos and wrote the pdb file into a conf file, so I couldn't connect it all the time, so don't be careless.
4. Start pure-ftpd
# cd / usr/local/pure-ftpd/
#. / sbin/pure-config.pl. / etc/pure-ftpd.conf
A successful startup displays the following message:
Running: / usr/local/pure-ftpd/sbin/pure-ftpd-A-B-C8-D-fftp-H-I15-lpuredb:/usr/local/pure-ftpd/etc/pureftpd.conf-M4-s-U133 fftp 022-u100-g/usr/local/pure-ftpd/var/run/pure-ftpd.pid-k99-Z
Restart: killall pure-ftpd
/ usr/local/pure-ftpd/sbin/pure-config.pl / usr/local/pure-ftpd/etc/pure-ftpd.conf
You can also define the PATH environment variable yourself, which is defined in the / etc/profile.d/path.sh file:
[root@jinge ~] # pure-config.pl / usr/local/pure-ftpd/etc/pure-ftpd.conf
Running: / usr/local/pure-ftpd/sbin/pure-ftpd-A-B-C8-D-fftp-H-I15-lpuredb:/usr/local/pure-ftpd/etc/pureftpd.conf-M4-s-U133 fftp 022-u100-g/usr/local/pure-ftpd/var/run/pure-ftpd.pid-k99-Z
5. Set up an account
The account used by pure-ftpd is not a Linux system account, but a virtual account, because it is more secure.
# mkdir / jin/www
# useradd www / / create a user www
# chown-R www:www / jin/www/ modify user ownership and group
# usr/local/pure-ftpd/bin/pure-pw useradd ftp_user1-uwww-d / jin/www/
(add user command: pure-pw
User who logs in to FTP: ftp_user1
-u the specified user is: system user
The directory after-d is the home directory of the ftp_user1 account, and ftp_user1 can only access its home directory / jin/www/)
# / usr/local/pure-ftpd/bin/pure-pw mkdb / / create a user information database file
# / usr/local/pure-ftpd/bin/pure-pw list / / list the current ftp account
# / usr/local/pure-ftpd/bin/pure-pw userdel ftp_user1 / / Delete an account
6. Test pure-ftpd
Remote connection testing (testing with another machine):
Server ip (native) is 192.168.226.3
Client ip (remote) is 192.168.226.5
On the client machine, the tool you need to use for testing is: lftp
Install lftp:yum install-y lftp
Test: lftp ftp_user1@192.168.226.3
Check the log: cat / var/log/messages
View the command in lftp:?
Download the file to the current directory: get 11.txt
Create a file in the client and upload it to the server:
Client:
Server:
Question 1:
At this time, if you log in to ftp, you will be prompted.
421 Unable to read the indexed puredb file (or old format detected)-Try pure-pw mkdb
Execution
# / usr/local/pureftpd/bin/pure-pw mkdb
Log in again and everything will be fine. Execute this command to have pureftpd generate / usr/local/pureftpd/etc/pureftpd.pdb based on / usr/loca/pureftpd/etc/pureftpd.passwd (this file is automatically generated when pure-pw useradd is executed)
At this point, the server is running normally.
Then use pure-pw useradd to add another ftp account to log in, and then prompt "verification failed". It is not possible to restart pureftpd. After being depressed for a long time, you can find the reason:
After executing the command of pure-pw, only the pureftpd.passwd file is changed, and the pureftpd.pdb must be regenerated by pure-pw mkdb to take effect.
I said that it would not work to add an account to the server I just took over because the pure-pw mkdb was not executed.
If there is an error and you can't log in, you should first check the log file to see what the error is: cat / var/log/messages
Question 2:
I used two virtual machines to do the experiment.
Server: a pure-ftpd (192.168.226.4) service has been built.
Client: the other one is not built (192.168.226.6) the service
(1) in the virtual machine where the pure-ftpd service is built, start after configuring the configuration file.
(2) the virtual machine without pure-ftpd service is used for connection, and the tool used for connection is lftp. If there is no yum installation, connect to the virtual machine and lftp ftp_user1@192.168.226.4.
After entering, ls, keep saying that the connection can not be connected, what is the problem?
Fault check:
1. First of all, I look at the cat / var/log/messages log file in the server to see what error it indicates. I don't know what the problem is. There is no pure-ftpd log in the log (I will know later).
two。 After checking that the log files were unsuccessful, I went to check the configuration files for configuration errors, one by one, but I focused on whether .pdb files and .pid files were generated.
3. After viewing the configuration file, I typed it on the command line
Cat / usr/local/pure-ftpd/etc/pureftpd.pdb, if there is, it's fine.
Cat / usr/local/pure-ftpd/var/run/pure-ftpd.pid / / enter said that the command can not be found, so there is no this file, and finally found the problem, so how to solve this problem?
Solution: my approach is to create / usr/local/pure-ftpd/var/run/pure-ftpd.pid directly
There is no var directory or run directory, so you have to create a directory first.
4. Restart the pure-ftpd service
Killall pure-ftpd / / Kill first
/ usr/local/pure-ftpd/sbin/pure-config.pl / usr/local/pure-ftpd/etc/pure-ftpd.conf / / start
5. Test on the client
The test found that there was still something wrong.
6. Check the log cat / var/log/messages
After the error is found, check the log. There was no log for pure-ftpd before, because no pid file was generated, so there was no log.
Now check the log, cat / var/log/messages, and come out the log of pure-ftpd. The error message is as follows:
Dec 25 17:38:58 localhost pure-ftpd: (? @? [ERROR] Unable to start a standalone server: [Address already in use]
Dec 25 17:41:08 localhost kernel: eth0: link down
Dec 25 17:41:20 localhost kernel: eth0: link up
Dec 25 17:41:34 localhost kernel: eth0: link down
Dec 25 17:41:44 localhost kernel: eth0: link up
Dec 25 17:46:20 localhost kernel: eth0: link down
Dec 25 17:46:30 localhost kernel: eth0: link up
After I found this information, I began to check it, but I couldn't find it on the Internet, and then I tried it myself. It said that there was a problem with eth0 and that the address was occupied, so I thought it might be the problem with the network, so I typed ifconfig on the server and the client, and got the following information:
Server:
[root@localhost pure-ftpd] # ifconfig
Eth0 Link encap:Ethernet HWaddr 00:0C:29:E4:CC:70
Inet addr:192.168.226.4 Bcast:192.168.226.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fee4:cc70/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7030 errors:0 dropped:0 overruns:0 frame:0
TX packets:5759 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:1163332 (1.1 MiB) TX bytes:1440044 (1.3 MiB)
Interrupt:19 Base address:0x2000
Client:
[root@localhost opt] # ifconfig
Eth2 Link encap:Ethernet HWaddr 00:0C:29:7B:C6:51
Inet addr:192.168.226.6 Bcast:192.168.226.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fe7b:c651/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3488 errors:0 dropped:0 overruns:0 frame:0
TX packets:2810 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:1079817 (1.0 MiB) TX bytes:363778 (355.2 KiB)
Interrupt:19 Base address:0x2000
Found that the problem lies, the client side of the network card shows eth2, so does it have anything to do with this?
So, I opened another virtual machine to connect to the server's pure-ftpd, and sure enough, the network card displayed on this virtual machine is eth0, so I think it should be the reason for the network card mismatch, and this problem has been solved.
The new virtual machine:
[root@jinge ~] # ifconfig
Eth0 Link encap:Ethernet HWaddr 00:0C:29:A4:00:54
Inet addr:192.168.226.3 Bcast:192.168.226.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fea4:54/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:39 errors:0 dropped:0 overruns:0 frame:0
TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:5374 (5.2 KiB) TX bytes:6162 (6.0 KiB)
Interrupt:19 Base address:0x2000