美文网首页
PureFtpd 服务

PureFtpd 服务

作者: fangfc | 来源:发表于2018-12-23 01:20 被阅读0次

1. 概述

  • Pure-FTPd 是一个免费的FTP服务器, 相比较传统的vsftpd 功能更加强大, 性能稳定.
  • 支持多种余元编写客户端程序.
  • 支持使用使用 SSL/TLS 加密.
  • 支持使用数据库存储和管理账户.

2. 安装和配置

2.1 源码包安装

  • 下载源码包并解压
[root@node10009 src]# ls -lh ./pure-ftpd-1.0.47.tar.bz2 
-rw-r--r-- 1 root root 478K Jun  4  2018 ./pure-ftpd-1.0.47.tar.bz2
[root@node10009 src]# tar jxf pure-ftpd-1.0.47.tar.bz2 
[root@node10009 src]# cd pure-ftpd-1.0.47
[root@node10009 pure-ftpd-1.0.47]# 
  • 预编译
[root@node10009 pure-ftpd-1.0.47]# ./configure --prefix=/opt/app/pureftpd --with-capabilities --with-sendfile --with-paranoidmsg --with-altlog --with-puredb --with-pam --with-cookie --with-throttling --with-ratios --with-quotas --with-ftpwho --with-welcomemsg --with-uploadscript --with-vritualhosts --with-diraliases --with-puruserlimits --with-mysql --with-privsep --with-rfc2640 --without-bonjour

  • 编译并安装
[root@node10009 pure-ftpd-1.0.47]# make -j4
...
[root@node10009 pure-ftpd-1.0.47]# make install
...
[root@node10009 pure-ftpd-1.0.47]# ls /opt/app/pureftpd/
bin  etc  sbin  share
  • 安装ftp 客户端
[root@node10009 pureftpd]# yum -y install ftp
...
Installed:
  ftp.x86_64 0:0.17-67.el7

Complete!

2.2 配置

  • 目录以及用户设置
### 添加用户和用户和组
[root@node10009 pureftpd]# groupadd pureftp
[root@node10009 pureftpd]# useradd -g pureftp -d /dev/null -s /sbin/nologin -r pureftp

### 创建目录和 ftp 用户
[root@node10009 pureftpd]# mkdir -p /opt/ftp/share
[root@node10009 pureftpd]# ./bin/pure-pw useradd testuser1 -u pureftp -d /opt/ftp/share/
Password: 
Enter it again: 
  • 编辑配置文件, 指定 用户数据库
[root@node10009 pureftpd]# ./bin/pure-pw mkdb
[root@node10009 pureftpd]# vim etc/pure-ftpd.conf 
    ...
     PureDB                       /opt/app/pureftpd/etc/pureftpd.pdb
    ...
  • 添加测试文件, 并设置好目录权限
[root@node10009 pureftpd]# echo 'hello' > /opt/ftp/share/a.txt 
[root@node10009 pureftpd]# chown -R pureftp. /opt/ftp/share/
  • 启动服务
[root@node10009 pureftpd]# ./sbin/pure-ftpd /opt/app/pureftpd/etc/pure-ftpd.conf 
[root@node10009 pureftpd]# ss -tan | grep 21
LISTEN     0      9            *:21                       *:*                  
LISTEN     0      9           :::21                      :::*                  
[root@node10009 pureftpd]# 

2.3 测试

  • 登陆测试
[root@node10009 pureftpd]# ftp localhost
Trying ::1...
Connected to localhost (::1).
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 18:23. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
Name (localhost:root): testuser1
331 User testuser1 OK. Password required
Password:
230 OK. Current directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
  • 下载测试
ftp> ls
229 Extended Passive mode OK (|||33927|)
150 Accepted data connection
drwxr-xr-x    2 958        pureftp            19 Dec 22 17:45 .
drwxr-xr-x    2 958        pureftp            19 Dec 22 17:45 ..
-rw-r--r--    1 958        pureftp             6 Dec 22 17:45 a.txt
226-Options: -a -l 
226 3 matches total
ftp> get a.txt 
local: a.txt remote: a.txt
229 Extended Passive mode OK (|||44663|)
150 Accepted data connection
226-File successfully transferred
226 0.000 seconds (measured here), 119.30 Kbytes per second
6 bytes received in 2.4e-05 secs (250.00 Kbytes/sec)
ftp> 
  • 上传测试
ftp> put /home/fangfc/b.txt b.txt
local: /home/fangfc/b.txt remote: b.txt
229 Extended Passive mode OK (|||9919|)
150 Accepted data connection
226-File successfully transferred
226 0.000 seconds (measured here), 63.02 Kbytes per second
6 bytes sent in 3.4e-05 secs (176.47 Kbytes/sec)
ftp> ls
229 Extended Passive mode OK (|||41164|)
150 Accepted data connection
drwxr-xr-x    2 958        pureftp            32 Dec 22 18:25 .
drwxr-xr-x    2 958        pureftp            32 Dec 22 18:25 ..
-rw-r--r--    1 958        pureftp             6 Dec 22 17:45 a.txt
-rw-r--r--    1 958        pureftp             6 Dec 22 18:25 b.txt
226-Options: -a -l 
226 4 matches total
ftp> 

3. 配置使用MySQL 登陆

3.1 MySQL 相关设置

  • 创建用于存储pure-ftp 用户 的数据库和数据表
MySQL [(none)] > CREATE  database pureftp DEFAULT CHARACTER SET=utf8;
Query OK, 1 row affected (0.00 sec)

MySQL [(none)] > use pureftp
MySQL [pureftp] > 

CREATE TABLE `ftpuser` (
    `user` VARCHAR(20) NOT NULL,
    `password` VARCHAR(255) NOT NULL,
    `uid` INT NOT NULL default '-1',
    `gid` INT NOT NULL default '-1',
    `dir` VARCHAR(255) NOT NULL,
    `status` TINYINT NOT NULL DEFAULT '0',
    PRIMARY KEY(User)
)ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;

Query OK, 0 rows affected (0.02 sec)
  • 创建 pureftpd 连接数据库的用户.
MySQL [pureftp] > GRANT ALL ON pureftp.* TO 'pureftp'@'127.0.0.1' IDENTIFIED BY 'pureftp';
Query OK, 0 rows affected, 1 warning (0.01 sec)

MySQL [pureftp] > FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)
  • 插入用户数据
MySQL [pureftp] > INSERT INTO `ftpuser`(`user`, `password`, `uid`, `gid`, `dir`,`status`) VALUES('user1', MD5('123'), 958,, 2001
Query OK, 1 row affected (0.01 sec)

MySQL [pureftp] > SELECT * FROM `ftpuser`;
+-------+----------------------------------+-----+-------+----------------+--------+
| user  | password                         | uid | gid   | dir            | status |
+-------+----------------------------------+-----+-------+----------------+--------+
| user1 | 202cb962ac59075b964b07152d234b70 | 958 | 2001 | /opt/ftp/share |      1 |
+-------+----------------------------------+-----+-------+----------------+--------+
1 row in set (0.01 sec)

3.2 修改配置文件

  • 修改主配置文件 /opt/app/pureftp/etc/pure-ftpd.conf
## 1. 注释 PureDB 项
# PureDB                       /opt/app/pureftpd/etc/pureftpd.pdb
...
## 2. 设置 MySQLConfigFile 
 MySQLConfigFile              /opt/app/pureftp/etc/pureftpd-mysql.conf
  • /opt/app/pureftp/etc/pureftp-mysql.conf
MYSQLServer     127.0.0.1
MYSQLPort       3306
MYSQLSocket     /tmp/mysql.sock
MySQLDatabase   pureftp
MYSQLUser       pureftp
MYSQLPassword   pureftp
MySQLCrypt      md5 

MYSQLGetPW SELECT password FROM ftpuser WHERE user ='\L' AND status=1
MYSQLGetUID SELECT uid FROM ftpuser WHERE user ='\L'  AND status=1
MYSQLGetGID SELECT gid FROM ftpuser WHERE user ='\L'  AND status=1
MYSQLGetDir SELECT dir FROM ftpuser WHERE user = '\L' AND status=1

3.3 测试

  • 登陆
[root@node10009 ~]# ftp localhost
Trying ::1...
Connected to localhost (::1).
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 00:47. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
Name (localhost:root): user1
331 User user1 OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
  • 下载
ftp> ls
229 Extended Passive mode OK (|||16372|)
150 Accepted data connection
drwxr-xr-x    2 958        pureftp            32 Dec 22 18:25 .
drwxr-xr-x    2 958        pureftp            32 Dec 22 18:25 ..
-rw-r--r--    1 958        pureftp             6 Dec 22 17:45 a.txt
-rw-r--r--    1 958        pureftp             6 Dec 22 18:25 b.txt
226-Options: -a -l 
226 4 matches total
ftp> get a.txt /root/test/a.txt
local: /root/test/a.txt remote: a.txt
229 Extended Passive mode OK (|||15025|)
150-Accepted data connection
150 The computer is your friend. Trust the computer
226-File successfully transferred
226 0.000 seconds (measured here), 136.53 Kbytes per second
6 bytes received in 2.3e-05 secs (260.87 Kbytes/sec)
  • 上传
[root@node10009 ~]# mkdir test
[root@node10009 ~]# cd test
[root@node10009 test]# echo 'hello' > abc.txt
...
ftp> put /root/test/abc.txt  abc.txt
local: /root/test/abc.txt remote: abc.txt
229 Extended Passive mode OK (|||58248|)
150 Accepted data connection
226-File successfully transferred
226 0.000 seconds (measured here), 12.13 Kbytes per second
6 bytes sent in 3.3e-05 secs (181.82 Kbytes/sec)
ftp> 

END

相关文章

  • PureFtpd 服务

    1. 概述 Pure-FTPd 是一个免费的FTP服务器, 相比较传统的vsftpd 功能更加强大, 性能稳定. ...

  • LNMP下FTP服务器的安装和使用

    FTP是网站文件维护中使用比较多的,目前LNMP一键安装包中有Pureftpd和Proftpd服务器安装脚本,LN...

  • Pure-ftp

    pure-ftpd-1.0.44.tar.gzwget http://download.pureftpd.org/...

  • pure_ftpd 安装及配置

    下载 : https://download.pureftpd.org/pub/pure-ftpd/release...

  • linux安装pureftpd

    1、下载软件 2、安装pure-ftp 3、配置文件 3.1增删用户并生产数据文件 3.2 删除用户 3.3 查询...

  • LNMP:pureftpd+pureadmin

    首先,需要LAMP或者LNMP环境 安装包 pure-ftpd-1.0.36.tar.gz 点我...

  • 零星小碎

    1. Lnmp下pureftpd新建FTP账户权限不足解决方法 chattr -i /default/.user....

  • lnmp 创建ftp用户

    以下lnmp版本为1.3 1、进入lnmp解压后的目录,执行:./pureftpd.sh 直接回车,等待安装成功...

  • 服务服务服务

    今天下班回家的必经之路,被掉落的通信线阻隔了,意外可以理解,但是昨天已经发生了,为什么今天还没有处理啊?这个...

  • 百亿元的智力服务平台市场,「站场」想用自动化流程模式走“京东模式

    (转载)智力服务包括信息服务、中介服务、咨询服务、策划服务、认证服务、设计服务、律师服务、会计服务、翻译服务、报关...

网友评论

      本文标题:PureFtpd 服务

      本文链接:https://www.haomeiwen.com/subject/zelgkqtx.html