共计 6127 个字符,预计需要花费 16 分钟才能阅读完成。
ftp == file transfer protocol 文件传输协议,使用 ftp 服务,可以上客户端远程下载和上传服务端的文件。系统自带的 ftp 工具是 vsftpd,我们也可以使用 pure-ftpd 工具。
下载 pure-ftpd 的链接:
官网:www.pureftpd.org
教程:http://www.linuxidc.com/Linux/2017-03/141701.htm
服务端 192.168.147.137:
进入源码目录:
[root@cp1 src]# cd /usr/local/src
下载安装包:
[root@cp1 src]# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.42.tar.bz2
解压安装包:
[root@cp1 src]# tar jxvf pure-ftpd-1.0.42.tar.bz2
进入安装目录:
[root@cp1 src]# cd pure-ftpd-1.0.42
配置安装选项:
[root@cp1 pure-ftpd-1.0.42]# ./configure –prefix=/usr/local/pureftpd –without-inetd –with-altlog –with-puredb –with-throttling –with-peruserlimites –with-tls
编译:
[root@cp1 pure-ftpd-1.0.42]# make
安装:
[root@cp1 pure-ftpd-1.0.42]# make install
创建配置文件目录:
[root@cp1 pure-ftpd-1.0.42]# mkdir -p /usr/local/pureftpd/etc
拷贝模板配置文件:
[root@cp1 pure-ftpd-1.0.42]# cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
拷贝启动文件:
[root@cp1 pure-ftpd-1.0.42]# cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
更改启动文件权限:
[root@cp1 pure-ftpd-1.0.42]# chmod 755 /usr/local/pureftpd/sbin/pure-config.pl
编辑配置文件:
[root@cp1 pure-ftpd-1.0.42]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
修改内容如下:
ChrootEveryone yes BrokenClientsCompatibility no MaxClientsNumber 50 Daemonize yes MaxClientsPerIP 8 VerboseLog no DisplayDotFiles yes AnonymousOnly no NoAnonymous no SyslogFacility ftp DontResolve yes MaxIdleTime 15PureDB /usr/local/pureftpd/etc/pureftpd.pdbLimitRecursion 3136 8 AnonymousCanCreateDirs no MaxLoad 4 AntiWarez yes Umask 133:022 MinUID 100 AllowUserFXP no AllowAnonymousFXP no ProhibitDotFilesWrite no ProhibitDotFilesRead no AutoRename no AnonymousCantUpload noPIDFile /usr/local/pureftpd/var/run/pure-ftpd.pidMaxDiskUsage 99 CustomerProof yes
(最小 UID 为 100,映射的 UID 要大于这个值,/usr/local/pureftpd/etc/pureftpd.pdb 为存放用户名密码的库文件)
创建一个测试目录:
[root@cp1 pure-ftpd-1.0.42]# mkdir /tmp/ftp
改变其属主:
[root@cp1 pure-ftpd-1.0.42]# chown -R rachy /tmp/ftp/
添加一个用于登陆 ftp 服务器的虚拟用户 ftpuser1,并将系统用户 rachy 映射到该虚拟用户:
[root@cp1 pure-ftpd-1.0.42]# /usr/local/pureftpd/bin/pure-pw useradd ftpuser1 -urachy -d /tmp/ftp/
Password:
Enter it again:
生成密码库文件:
[root@cp1 pure-ftpd-1.0.42]# /usr/local/pureftpd/bin/pure-pw mkdb
(也可以查看内容:/usr/local/pureftpd/bin/pure-pw list)
(也可以删除用户:/usr/local/pureftpd/bin/pure-pw userdel ftpuser1)
启动 pureftpd 服务:
[root@cp1 pure-ftpd-1.0.42]# /usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
Running: /usr/local/pureftpd/sbin/pure-ftpd -A -c50 -B -C8 -D -fftp -H -I15 -lpuredb:/usr/local/pureftpd/etc/pureftpd.pdb -L3136:8 -m4 -s -U133:022 -u100 -g/usr/local/pureftpd/var/run/pure-ftpd.pid -k99 -Z
查看进程:
[root@cp1 pure-ftpd-1.0.42]# ps aux | grep pure
root 7146 0.0 0.0 9000 588 ? Ss 21:45 0:00 pure-ftpd (SERVER)
root 7148 0.0 0.0 5980 756 pts/0 S+ 21:46 0:00 grep pure
查看端口:
[root@cp1 pure-ftpd-1.0.42]# netstat -lnp | grep pure
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 7146/pure-ftpd (SER
tcp 0 0 :::21 :::* LISTEN 7146/pure-ftpd (SER
客户端 192.168.147.138:
安装 lftp 命令:
[root@cp2 ~]# yum install -y lftp
登陆 ftp 服务器:
[root@cp2 ~]# lftp ftpuser1@192.168.147.137
口令:
lftp ftpuser1@192.168.147.137:~>?
登陆之后,输入?查看 ftp 支持的命令
下载文件:
[root@cp2 download]# ls
2.txt
[root@cp2 download]# lftp ftpuser1@192.168.147.137
口令:
lftp ftpuser1@192.168.147.137:~> ls
drwxr-xr-x 2 502 0 4096 Feb 26 21:57 .
drwxr-xr-x 2 502 0 4096 Feb 26 21:57 ..
-rw-r–r– 1 0 0 5 Feb 26 21:57 1.txt
lftp ftpuser1@192.168.147.137:/> get 1.txt
5 bytes transferred
lftp ftpuser1@192.168.147.137:/> exit
[root@cp2 download]# ls
1.txt 2.txt
[root@cp2 download]#
上传文件:
lftp ftpuser1@192.168.147.137:~> ls
drwxr-xr-x 2 502 0 4096 Feb 26 21:57 .
drwxr-xr-x 2 502 0 4096 Feb 26 21:57 ..
-rw-r–r– 1 0 0 5 Feb 26 21:57 1.txt
lftp ftpuser1@192.168.147.137:/> put 2.txt
5 bytes transferred
lftp ftpuser1@192.168.147.137:/> ls
drwxr-xr-x 2 502 0 4096 Feb 26 21:59 .
drwxr-xr-x 2 502 0 4096 Feb 26 21:59 ..
-rw-r–r– 1 0 0 5 Feb 26 21:57 1.txt
-rw-r–r– 1 502 rachy 5 Feb 26 21:56 2.txt
lftp ftpuser1@192.168.147.137:/>
也可以使用 ftp 命令登陆,跟 lftp 类似:
安装 ftp 客户端:
[root@cp2 download]# yum install -y ftp
登录 ftp 服务器:
[root@cp2 download]# ftp 192.168.147.137
Connected to 192.168.147.137 (192.168.147.137).
220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
220-You are user number 1 of 50 allowed.
220-Local time is now 22:01. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (192.168.147.137:root): ftpuser1
331 User ftpuser1 OK. Password required
Password:
230 OK. Current directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,147,137,210,129)
150 Accepted data connection
drwxr-xr-x 2 502 0 4096 Feb 26 22:03 .
drwxr-xr-x 2 502 0 4096 Feb 26 22:03 ..
-rw-r–r– 1 0 0 5 Feb 26 21:57 1.txt
226-Options: -a -l
226 3 matches total
下载文件:
ftp> get 1.txt
local: 1.txt remote: 1.txt
227 Entering Passive Mode (192,168,147,137,206,50)
150 Accepted data connection
226-File successfully transferred
226 0.000 seconds (measured here), 14.27 Kbytes per second
5 bytes received in 3.1e-05 secs (161.29 Kbytes/sec)
ftp> exit
221 Goodbye. You uploaded 0 and downloaded 1 kbytes.
[root@cp2 download]# ls
1.txt 2.txt
上传文件:
ftp> put 2.txt
local: 2.txt remote: 2.txt
227 Entering Passive Mode (192,168,147,137,130,188)
150 Accepted data connection
226-File successfully transferred
226 0.001 seconds (measured here), 7.76 Kbytes per second
5 bytes sent in 0.000164 secs (30.49 Kbytes/sec)
ftp> ls
227 Entering Passive Mode (192,168,147,137,136,65)
150 Accepted data connection
drwxr-xr-x 2 502 0 4096 Feb 26 22:05 .
drwxr-xr-x 2 502 0 4096 Feb 26 22:05 ..
-rw-r–r– 1 0 0 5 Feb 26 21:57 1.txt
-rw-r–r– 1 502 rachy 5 Feb 26 22:05 2.txt
226-Options: -a -l
226 4 matches total
ftp>
Windows 上只需安装 ftp 客户端即可访问 ftp 服务器。
Pureftpd http://www.linuxidc.com/Linux/2016-11/137619.htm
PureFtp+PureAdmin: 实现基于虚拟账号的 FTP 服务器 http://www.linuxidc.com/Linux/2013-06/85728.htm
PureFtp+PureAdmin 安装配置 http://www.linuxidc.com/Linux/2014-06/103267.htm
Vsftpd 虚拟用户的配置及 PureFtp 配置解析 http://www.linuxidc.com/Linux/2012-12/76502.htm
CentOS7.2 安装 FTP(pure-ftpd-1.0.43) http://www.linuxidc.com/Linux/2016-10/135971.htm
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/142187.htm