免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6409 | 回复: 15
打印 上一主题 下一主题

[FTP] wolfg版主,好久不见了,我来毛遂自荐一篇吧 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-15 13:11 |只看该作者 |倒序浏览
本帖最后由 初学vb 于 2010-07-15 14:44 编辑

先说说废话吧,自从CU改版,又恰逢本人工作变动,一直以来都没有再回来了,不过还是一直牵挂CU,不是因为别的,你试试,每天十几个网友加MSN,400多短消息!呵呵,不关注也不行啊。中间CU数次改版,由于数据丢失本人甚至回到新手阶段,可也一直没有忘记CU,缘分吧。

曾经不知天高地厚的在FTP区发表过

vsftp配置大全---超完整版
人来疯技术文档再现江湖之pureftpd使用大全

开办过人来疯技术论坛,Cacti中国社区,虽然都已终结,但在这其中我丰富了自己的经验和阅历,我不希望广大的CUers们再重蹈我的覆辙,而只有不受限制的文档,它们就和日记一样,能详细记录当时的状态,当时的想法,能完整的呈现给大家,所以文学才会一直久经不衰,希望看完我的这些废话,大家能真正认识到技术文档的重要性,切实的记录起来,到最后你会发现,这是你技术人生真正的财富。


===================================废话说完了,言归正传==================================

本文档名称为

glftpd的安装及使用--完整版

版权信息:可随意转载,但希望注明转自CU 初学vb

大家现在还在研究vsftpd or pureftpd 吗? 今天我带来一个在 TOP SITE 里用得比较多的glftpd的安装及使用文档,仅供大家参考学习

安装环境rhel5u2

用YUM工具检查环境
yum install -y gcc gcc-devel openssl openssl-devel xinetd

(估计都应该默认安装完成,这里只是检查一下。我如何在RHEL下运行的 YUM 如果你感兴趣,我可以再开一贴介绍)

论坛徽章:
0
2 [报告]
发表于 2010-07-15 13:43 |只看该作者
glftpd的官方网站是http://www.glftpd.com/,目前的最新版本是2.0.1 2005-12-25发布的,到现在也没有什么大的安全漏洞,经典程序啊!

# tar -zxvf glftpd-LNX_2.01.tgz
解压完成后
# cd glftpd-LNX_2.01
# ./installgl.sh

如果被告知权限被deny了,请用chmod +x installgl.sh 修复吧

进行安装,这个比较简单,我大致说说

--== WE MAKE FILES TRANSFER ==--


-----------------------------------------------------------
GLFTPD INSTALLER v2.0.1 (linux)

Originally done by jehsom and dn.
Made ready for the new era by turranius and psxc.
-----------------------------------------------------------


Before we begin: If this installer fails on your system, please
let the devs know. You find us on irc (efnet) in #glftpd. Thank you.
Also, any bugs found in glftpd itself should be reported either to
the board @ http://www.glftpd.com, in the irc channel, or both.

Press <enter> to continue.
这块你直接回车

=============================
1. TCPD SETUP:
--------------

Do you wish to use tcpd? If you are not sure then you should not
use it. If you decided to change this at a later time, please
search for tcpd in glftpd.docs for the required changes.

Use tcpd? [Y]es [N]o:
小知识:tcpd程序是负责检测telnet、FTP等服务请求的。一旦有服务请求到来,inetd进程将启动tcpd进程。tcpd在日志文件中记录该请求,并且完成其它一些检测工作。如果一切正常通过,tcpd将启动相应的服务器进程,然后结束。

我输入 N 不选择,然后回车继续
==========================
2. JAIL SETUP:
--------------

Do you want to run glftpd in a "Jailed" environment? In this
environment a private directory will be created and glftpd will
be installed inside. Regular shell users will not be able to get
inside this private directory. The glftpd.conf is also moved
inside for added security and a new group will be created so
you and other users you specify can access glftpd through the shell.

Use a jailed environment? [Y]es [N]o:
这里是问你是否要把GLFTPD的文件方到一个的单独的文件夹
我选择Y ,回车继续
=============================
3 GLFTPD BASE SETUP:
--------------

Please enter the private directory to install glftpd inside [/jail]:
叫你输入一个目录来存放
我输入 /usr/local/glftpd

==================
Do you want to create a private group? If you say no then only root will
be able to access glftpd. Otherwise you can add other shell users to the
group so they can access glftpd from the shell.

Use a private group? [Y]es [No]:
问你是否要建立一个私有组
我输入N 不建立
========================
4. SERVICE SETUP & MULTI-INSTALL:
---------------------------------

Enter a service name for glftpd. This name will be used as the
service name mapped to the port in /etc/services, the name
used in your (x)inetd settings, and the name of your config-file.
NOTE: If you (wish to) have multiple instances of glftpd on the
same box, you *must* to change this.
Press <enter> for the default (glftpd)>

直接回车使用默认

==========================
5. COMPILING SOURCES & COPYING LIBS:
---------------------------------
这里会输出一些提示

==========================
6. PORT AND SYSTEM SETUP:
-------------------------

Enter the port you would like glftpd to listen on [1337]:

要你选择FTP的端口
我选择21,你可以在这里设置其他端口
===============================
7. SSL/TLS SETUP:
-----------------

We will now create a certificate for SSL/TLS support. This step is
required.


Please specify location, inside /glftpd/glftpd,
to install the cert (ftpd-dsa.pem) [/etc]:

要求你输入一个名字 做为 SSL的证书名

我输入:cacti

========================================
9. FINISH:
----------

Congratulations, glFtpD has been installed. Scroll up and note any errors
that needs fixing. ./installgl.debug contains a log of the installation process.

To get your site running, you must edit /glftpd/glftpd.conf according to
the instructions in /glftpd/glftpd/docs/glftpd.docs.
For help, visit #glftpd on EFnet AFTER you've read (not skimmed) the docs/faq.

After configuring glftpd, visit the following websites for additional
scripts to give your site some style!:
Turranius - http://www.grandis.nu/glftpd
Jehsoms - http://runslinux.net/
dn's and ip's - http://www.chimera-coding.com
D-ViBE's collection - http://www.glftpd.at

The official glftpd homepage is located at http://www.glftpd.com

Thanks for your support!
the glFtpD team

到此安装结束了

论坛徽章:
0
3 [报告]
发表于 2010-07-15 14:11 |只看该作者
安装很简单,glftpd基本都帮你想到了,关键是使用

首先我们需要重启:xinetd
# /etc/init.d/xinetd restart

修改配置文件,让我们可以从外部主机登录。

# vi /usr/local/glftpd/glftpd/ftp-data/users/glftpd
找到:
IP *@127.0.0.1
改为:IP *@*
意思就是不限制IP,等你在客户端加完用户再改回来。
再运行下:/etc/init.d/xinetd restart ,让glftpd读新的配置文件

然后我们回到自己的windows机器,我想大多数人都用windows吧,有个很好用的软件叫flashfxp,大家都知道吧

用flashfxp登录你的FTP
用户名和密码都是glftpd

登录后按CTRL+R调出输入命令界面,在这里就可以添加用户了

以下是一些命令的使用方法(不仅仅限于添加用户)

添加用户
命令格式:
SITE ADDUSER username password
eg:添加一个用户名为test,密码为test的用户
site adduser test test

删除用户
命令格式:
SITE DELUSER username
eg:删除一个名为test的用户
site deluser test

修改用户密码
命令格式:
SITE CHPASS username password
eg:修改用户test的密码为12345
site chpass test 12345

修改操作者自身密码
命令格式:
SITE PASSWD password
eg:修改操作者自身密码为test
site passwd test

重命名用户
命令格式:
SITE RENUSER old_username new_username
eg:重命名用户test为test1
site renuser test test1

添加登录IP
命令格式:
SITE ADDIP username ident@ip1 ident@ip2 … ident@ip10
eg1:给用户test增加登录ip1.2.3.4,test用户只能在该ip上登录
site addip test *@1.2.3.4
eg2:给用户test增加登录ip段1.2.3.0,test用户只能在该ip段上登录
site addip test *@1.2.3.*
eg3:给用户同时添加多个ip
site addip test *@1.2.3.4 *@1.2.3.5 *@1.3.4.5
eg4:用户test可以在任意ip登录
site addip test *@*

删除登录ip
命令格式:
SITE DELIP username ident@ip1 ident@ip2 … ident@ip10
eg:删除用户test的登录ip1.2.3.4(该登录ip必须已经先存在)
site delip test *@1.2.3.4

查看用户信息
命令格式:
SITE USER username
eg:查看用户test的信息
site user test

修改用户设置
这个命令是比较常用但也比较复杂的,现挑出其中部分常用的进行说明,你可以自己查看手册
命令格式:
SITE CHANGE username field value                  
SITE CHANGE user1 user2 field value
field表示要修改哪个设置,value表示设置值
常用的field如下所示:
ratio
max_dlspeed
max_ulspeed
max_sim_down
max_sim_up
timeframe # #
time_limit
flags
homedir
idle_time
num_logins # [#]
expires [yyyy-mm-dd]

以下对field进行说明
ratio
设置上传/下载比率,默认是1:3
命令格式:
SITE CHANGE username ratio value
eg:修改用户test的ratio为0(即不限制比率)
site change test ratio 0

注意:组管理员只能设置ratio为0或者3(表示1:3),在这儿多说1句,标准PT站的分享率是上传%下载的值

max_dlspeed
设置最大下载速度,单位为Kbytes/s
命令格式:
SITE CHANGE username max_dlspeed value
eg:修改用户test的最大下载速度为200KB/s
site change test max_dlspeed 200

max_ulspeed
设置最大上传速度,单位为Kbytes/s
命令格式参考max_dlspeed

max_sim_down
设置一个用户最大的下载线程数
命令格式:
SITE CHANGE username max_sim_down value
eg:设置用户test的最大下载线程数为2
site change test max_sim_down 2

max_sim_up
设置一个用户最大的上载线程数
命令格式参考max_sim_down

timeframe
设置一个用户可以登录的时间
命令格式:
SITE CHANGE username timeframe value value
eg1:设置用户test的登录时间为3:00 AM到10:00AM
site change test timeframe 3 10
eg2:设置用户test的登录时间为无限制
site change test timeframe 0 23

time_limit
设置一个用户登录到ftp所能停留的时间
命令格式:
SITE CHANGE username time_limit value
eg:设置用户test在ftp上停留的时间为2分钟,用户test登录到ftp 2分钟后会被断开连

site change test time_limit 2

homedir
设置一个用户的主目录
命令格式:
SITE CHANGE username homedir value
eg1:设置test用户的主目录为/incoming
site change test homedir /site/incoming
eg2:设置test用户的主目录为/pub
site change test homedir /site/pub
注意:设置主目录时必须在前面加/site/

idle_time
设置一个用户在ftp上的发呆时间,以second为单位
命令格式:
SITE CHANGE username idle_time value
eg:设置用户test的发呆时间为10秒
site change test idle_time 10

num_logins
设置ftp服务器上一个用户的最大登录数及同一ip的最大登录数
命令格式:
SITE CHANGE username num_logins value value
eg:设置用户test的最大登录数为30,同一ip最大登录数为2
site change test num_logins 30 2

expires [yyyy-mm-dd]
设置一个用户的过期时间
命令格式:
SITE CHANGE username expires yyyy-mm-dd
eg:设置用户test的过期时间为2010-7-14
site change test expires 2010-7-14

==================================待续===========================

论坛徽章:
0
4 [报告]
发表于 2010-07-15 14:16 |只看该作者
下面该说说用命令管理FTP状态了!!

查看用户的在线情况
命令格式:
SITE WHO
SITE SWHO

建议使用第二种方式查看用户在线情况,看到的信息要比第一种详细,而且查看到这些信息以后可以使用site kill的方式踢掉特定用户(用id来鉴别)的连接。

查看所在组用户的概况
命令格式:
SITE GINFO

踢出用户
命令格式:
SITE KICK username
SITE KILL pid

eg:踢出一个特定用户
site kick test
site kill 5432
5432是用户连接的pid,可以通过site swho来查看

查看服务器流量情况
命令格式:
SITE TRAFFIC

查看用户登录日志
命令格式
SITE LOGINS

论坛徽章:
0
5 [报告]
发表于 2010-07-15 14:20 |只看该作者
如果你是一个FTP管理员,建立好FTP后,你如何开展你的工作呢,我是这样做的!

site adduser test 12345678  //添加用户test并设置其密码为12345678

site change test ratio 0 //修改用户上传下载比(ratio)

site change test num_logins 30 2 //修改用户最大可同时连接ip数及同一ip可登录数量

site change test max_sim_down 2
site change test max_sim_up 2       //修改用户最大下载/上传线程数

site change test max_dlspeed 200
site change test max_upspeed 200  //修改用户最大下载/上传速度

site change test homedir /site/incoming  //修改用户主目录

site change test idle_time 120  //修改用户的发呆时间(秒)

site addip test *@121.111.* *@121.112.123.*  //给用户添加登录ip

测试用户设置
使用flashfxp来测试刚才的设置是否正确

论坛徽章:
0
6 [报告]
发表于 2010-07-15 14:34 |只看该作者
本帖最后由 初学vb 于 2010-07-15 16:58 编辑

写了半天,发现没有介绍glftpd的conf文件,其实这个文件基本都设置好了,我们修改的地方很少,我大概说说

sitename_short  CACTI  //FTP站点名

email           123@123.com  //管理员email

rootpath /glftpd/glftpd //glftpd主程序文件所在目录

datapath        /ftp-data  //自己设定放上传下载文件的主目录

welcome_msg     /ftp-data/misc/welcome.msg      *
goodbye_msg     /ftp-data/misc/goodbye.msg      *
newsfile        /ftp-data/misc/newsfile         *
banner          /ftp-data/misc/banner                    //各种服务器反馈信息

其他基本不需要修改,因为命令全搞定了,如果你有中文文件夹以及中文文件名的文件,找到如下两行

#path-filter    group   path/msgfile                    filters
path-filter     *      /ftp-data/misc/pathmsg          ^[-A-Za-z0-9_.()[:space:]]*$  ^\.  ^- =

把第二行注释掉即可

如果你需要解决不同文件夹同文件名不能上传的问题,找到如下两行
# dupecheck     how many days?  ignore file case like Windows?
dupe_check     7               no

将 dupe_check     7               no 注释掉即可

论坛徽章:
0
7 [报告]
发表于 2010-07-15 14:37 |只看该作者
关于glftpd优化(代码层面)

加快登录速度,请修改/etc/xinetd.d/glftpd 改为如下

service glftpd
{
    disable = no
    flags           = REUSE NAMEINARGS
    socket_type     = stream
    protocol        = tcp
    wait            = no
    user            = root
    server          = /jail/glftpd/bin/glftpd
    server_args     = -n 0 -I -l -i -o -r /jail/glftpd.conf -s /jail/glftpd/bin/glstrings.bin -z cert=/jail/glftpd/etc/ftpd-dsa.pem
}

论坛徽章:
0
8 [报告]
发表于 2010-07-15 14:38 |只看该作者
写完了,请大家评判吧,多多赐教,谢谢各位!!

论坛徽章:
1
巳蛇
日期:2014-12-29 11:22:41
9 [报告]
发表于 2010-07-15 14:59 |只看该作者
欢迎初学vb归来!

很不错的文章,非常详实,实战性很强,收藏了,感谢!

论坛徽章:
0
10 [报告]
发表于 2010-07-15 15:02 |只看该作者
谢谢陈总捧场啊!!哈哈!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP