当前位置: 首页 > 工具软件 > Pure-FTPd > 使用案例 >

linux ftp pure,linux下安装FTP(pure-ftpd)

苏君昊
2023-12-01

1、什么是FTP

FTP(file transfer protocol)文件传输协议,可以使主机之间共享文件。

2、使用pure-ftp搭建FTP服务

下载pure-ftp软件包[root@localhost src]# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.32.tar.bz2

解压安装包[root@localhost src]# tar jxvf pure-ftpd-1.0.32.tar.bz2

配置pure-ftp[root@localhost src]# cd pure-ftpd-1.0.32

[root@localhost pure-ftpd-1.0.32]# ./configure --prefix=/usr/local/pureftpd --without-inetd --with-altlog --with-puredb --with-throttling --with-peruserlimits --with-tls

编译安装[root@localhost pure-ftpd-1.0.32]# make && make install

查看/usr/local/pureftpd/目录下生成的文件[root@localhost pure-ftpd-1.0.32]# ls /usr/local/pureftpd/

bin sbin share

复制配置文件[root@localhost pure-ftpd-1.0.32]# mkdir -p /usr/local/pureftpd/etc/

[root@localhost pure-ftpd-1.0.32]# cd configuration-file/

[root@localhost configuration-file]# ls

Makefile Makefile.in pure-config.pl.in pure-config.py.in pure-ftpd.conf.in

Makefile.am pure-config.pl pure-config.py pure-ftpd.conf

[root@localhost configuration-file]# cp pure-ftpd.conf /usr/local/pureftpd/etc/

[root@localhost configuration-file]# cp pure-config.pl /usr/local/pureftpd/sbin/pure-config.pl

[root@localhost configuration-file]# chmod 755 /usr/local/pureftpd/sbin/pure-config.pl

编写配置文件pure-ftpd.conf[root@localhost configuration-file]# vim /usr/local/pureftpd/etc/pure-ftpd.conf

ChrootEveryone yes

//用户只能在他的家目录

BrokenClientsCompatibility no

MaxClientsNumber 50

//最大并发的用户

Daemonize yes

//在后台运行进程

MaxClientsPerIP 8

VerboseLog no

//If you want to log all client commands, set this to "yes".

DisplayDotFiles yes

AnonymousOnly no

//Don't allow authenticated users - have a public anonymous FTP only.

NoAnonymous no

//Disallow anonymous connections. Only allow authenticated users.

SyslogFacility ftp

DontResolve yes

// Don't resolve host names in log files. Logs are less verbose,

// butit uses less bandwidth. Set this to "yes" on very busy servers or

//if you don't have a working DNS.

MaxIdleTime 15

//Maximum idle time in minutes (default = 15 minutes)

PureDB /usr/local/pureftpd/etc/pureftpd.pdb

//用户数据库

LimitRecursion 3136 8

//'ls' recursion limits. The first argument is the maximum number offiles to be displayed.

//The second one is the max subdirectories depth

AnonymousCanCreateDirs no

//Are anonymous users allowed to create new directories ?

MaxLoad 4

//If the system is more loaded than the following //value,anonymous users aren't allowed to download.

AntiWarez yes

//Disallow downloading of files owned by "ftp", ie.files that were uploaded but not validated by a local admin.

Umask 133:022

//File creation mask. : .

MinUID 100

//Minimum UID for an authenticated user to log in.

AllowUserFXP no

//Allow FXP transfers for authenticated users.

AllowAnonymousFXP no

//Allow anonymous FXP for anonymous and non-anonymous users.

ProhibitDotFilesWrite no

// Users can't delete/write files beginning with a dot ('.')even if they own them.

ProhibitDotFilesRead no

// Prohibit *reading* of files beginning with a dot (.history, .ssh...)

AutoRename no

//Never overwrite files. When a file whoose name already exist is uploaded,

//it get automatically renamed to file.1, file.2, file.3, ...

AnonymousCantUpload no

// Disallow anonymous users to upload new files (no = upload is allowed)

PIDFile /usr/local/pureftpd/var/run/pure-ftpd.pid

//If your pure-ftpd has been compiled with standalone support,

//you can change the location of the pid file. The default is /var/run/pure-ftpd.pid

MaxDiskUsage 99

CustomerProof yes

//If you're sure all your users have some basic Unix knowledge,

//this feature is useless. If you're a hosting service, enable it.

创建FTP服务目录[root@localhost configuration-file]# mkdir /data/ftp

[root@localhost configuration-file]# useradd www

[root@localhost configuration-file]# passwd www

Changing password for user www.

New password:

BAD PASSWORD: it is too simplistic/systematic

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updated successfully.

[root@localhost configuration-file]# chown -R www:www /data/ftp //更改属主属组

用系统账号需创建虚拟FTP账号[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw useradd ftp1 -uwww -d/data/ftp

Password:

Enter it again:

//创建虚拟账号

[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw mkdb

//创建密码文件,二进制文件

[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw list

ftp1 /data/ftp/./

//列出虚拟账号

[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw useradd ftp2 -uwww -d /data/ftp

Password:

Enter it again:

][root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw passwd ftp2

Password:

Enter it again:

//修改虚拟账号密码

[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw userdel ftp2

//删除虚拟账号

[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw list

ftp1 /data/ftp/./

启动pure-ftp[root@localhost configuration-file]# /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@localhost configuration-file]# netstat -anpt |grep pure

tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 6721/pure-ftpd (SER

tcp 0 0 :::21 :::* LISTEN 6721/pure-ftpd (SER

访问pure-ftp[root@client ~]# lftp ftp1@192.168.0.104 //客户机

Password:

lftp ftp1@192.168.0.104:~> ls

drwxr-xr-x 5 504 www 4096 Apr 22 11:02 .

drwxr-xr-x 5 504 www 4096 Apr 22 11:02 ..

drwxr-xr-x 2 0 0 4096 Apr 22 11:02 aa

drwxr-xr-x 2 0 0 4096 Apr 22 11:02 bb

drwxr-xr-x 2 0 0 4096 Apr 22 11:02 cc

-rw-r--r-- 1 0 0 0 Apr 22 11:02 ee

-rw-r--r-- 1 0 0 0 Apr 22 11:02 qq

-rw-r--r-- 1 0 0 0 Apr 22 11:02 ww

 类似资料: