在FreeBSD下安装ProFTPD [原创]

wandering 发表于 2006-01-20 00:51:32

在FreeBSD下安装ProFTPD [原创]

 
作者: wandering   E-mail: wandering_997@126.com 
 
http://www.proftpd.org
 
 
1. 安装proftpd
------------------
 
shell> tar zxvf proftpd-1.2.10.tar.gz
shell> cd proftpd-1.2.10
shell> ./configure --prefix=/usr/local/proftpd
shell> make
shell> make install
 
 
 
2. 创建ftpassswd命令
------------------------
 
http://www.castaglia.org/proftpd/contrib/ftpasswd 获得ftpasswd的perl源代码,
并保存为 /usr/local/proftpd/sbin/ftpasswd 。
 
shell> chmod 755 /usr/local/proftpd/sbin/ftpasswd
 
通过ftpasswd命令,可以对ProFTPD的虚拟用户进行管理。
 
shell> echo "wheel:*:0:" >> /usr/local/proftpd/etc/ftpd.group
 
shell> /usr/local/proftpd/sbin/ftpasswd --passwd --name=admin --uid=2001 --gid=0 --home=/ftp/admin --shell=/bin/bash --file=/usr/local/proftpd/etc/ftpd.passwd
...
Password: <new password>
Re-type password: <new password>
 
shell> /usr/local/proftpd/sbin/ftpasswd --passwd --name=tom --uid=2101 --gid=2000 --home=/ftp/tom --shell=/usr/sbin/nologin --file=/usr/local/proftpd/etc/ftpd.passwd
...
Password: <new password>
Re-type password: <new password>
 
之后会自动生成/usr/local/proftpd/etc/ftpd.passwd
 
shell> chmod -R 777 /ftp/admin
shell> chmod -R 777 /ftp/tom
要注意,因为虚拟用户并不在本地系统用户中存在,所以要设置虚拟用户可以访问的所有目录都允许其它用户写,这样才能保证虚拟用户正常增删文件。
 
 

3. 接下来配置proftpd.conf
-----------------------------
 
shell> vi /usr/local/proftpd/etc/proftpd.conf

ServerName                      "My FTP Server"
ServerType                      standalone
DefaultServer                   on
 
Bind                            10.210.66.130
ExtendedLog                     /var/log/proftpd read,write,auth
# 原来的设置项是ScoreboardPath,但现在版本的proftpd已不再支持,改用ScoreboardFile
ScoreboardFile                  /usr/local/proftpd/var/proftpd/proftpd.scoreboard
 
Port                            21
Umask                           022
 
MaxInstances                    50
MaxClients                      20
# 如果允许匿名访问或多人共用同一帐号,MaxHostsPerUser和MaxClientsPerUser不应设置过小,或不用设置
MaxClientsPerHost               3 "Sorry, only 3 connections allowed per user!"
MaxHostsPerUser                 1 "Sorry, only 1 host allowed per user!"
MaxClientsPerUser               1 "Sorry, only 1 connection allowed per user!"
TimeoutIdle                     600
TimeoutStalled                  10
 
# 不显示服务器相关信息, 如proftpd版本
ServerIdent                     off
# 禁用反向域名解析
UseReverseDNS                   off
 
# 支持FXP
AllowForeignAddress             on
# 支持被动模式
PassivePorts                    49152 65534
 
AllowOverwrite                  on
# 允许下载续传,默认即开启,但为了明确我显示地声明
AllowRetrieveRestart            on
# 允许上载续传
AllowStoreRestart               on
 
DisplayLogin                    welcome.msg
DisplayFirstChdir               .message

User                            nobody
Group                           nogroup
 

# 不要求有合法shell,直接效果是允许nologin用户和虚拟用户登录
RequireValidShell               off
# 设置用户验证顺序是先虚拟用户再本地用户
AuthOrder                       mod_auth_file.c mod_auth_unix.c
# 指定虚拟用户数据文件
AuthUserFile                    /usr/local/proftpd/etc/ftpd.passwd
# 指定虚拟组数据文件
AuthGroupFile                   /usr/local/proftpd/etc/ftpd.group
# ***除wheel组外其它所有组只能访问home目录内容,这里wheel需要在ftpd.group中定义
DefaultRoot                     ~ !wheel
# 虽然默认情况root不能ftp,但我仍然显式地声明它,也方便随时开启这个功能。
RootLogin                       off
 
 
<Limit SITE_CHMOD>
  DenyAll
</Limit>
 
 
<Anonymous ~ftp>
  User                          ftp
  Group                         ftp
 
  # We want clients to be able to login with "anonymous" as well as "ftp"
  UserAlias                     anonymous ftp
 
  # Limit the maximum number of anonymous logins,禁用匿名FTP
  MaxClients                    none "Sorry, anonymous is refused on this site!"
 
  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
  DisplayLogin                  welcome.msg
  DisplayFirstChdir             .message
 
  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE>
    DenyAll
  </Limit>
</Anonymous>
 
 
 
4. 启动proftpd
-------------------
shell> /usr/local/proftpd/sbin/proftpd
 
OK,到这里,我们的proftpd架设的ftp服务器就可以正常使用了。
 
现在用户tom拥有home目录的所有权限,但不能访问home以外的目录;
用户admin除了拥有home目录的所有权限之外,还可以访问home以外的目录,对这些目录的操作权限依赖于文件系统对目录的权限设置;
与其同时,本地系统用户(虚拟用户中无重名)也可以验证通过访问ftp
 
 
 
5. 配置自动运行
-------------------
shell> echo "/usr/local/proftpd/sbin/proftpd" >> /etc/rc.local
 
 
 
6. 禁用匿名FTP
------------------
 
方法一:
<Anonymous ~ftp>
  ...
  MaxClients None "Sorry, Anonymos is refused on this site!"
  ...
</Anonymous>
 
 
方法二:
<Anonymous ~ftp>
  ...
  <Limit LOGIN>
    DenyAll
  </Limit>
  ...
</Anonymous>
 
当然,用Limit ALL也是可以的。
 
方法三:
直接删除<Anonymous ~ftp>...</Anonymous>部分就可以了。
 
 
 
 
-----------------------------------------
2006/01/20 00:48 Created by Wandering
2006/01/23 16:35 Modified by Wandering
 
 
 
 
 
 
 
关键词(Tag): ftp unix install freebsd proftpd

收藏: QQ书签 del.icio.us 订阅: Google 抓虾

最新评论

发表评论

* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 
 

分类小组论坛
杂谈, 娱乐、八卦, 文学、艺术, 体育, 旅游、同城, 象牙塔, 情感, 时尚、生活, 星座, 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定