Proftpd 安装配置

简介:

今天安装配置proftpd-1.3.4a ,现将我的一些过程和理解记录如下:

1、 下载安装

http://www.proftpd.org  可下载最新版本

安装时./configure  --prefix=PREFIX 选项。我是安装到/opt/proftpd

--sysconfdir=DIR 配置文件路径

2、 配置

[root@localhost home]# cd /opt/proftpd/
[root@localhost proftpd]# ls
bin  etc  include  lib  libexec  sbin  share  sys.log  var

创建nologin和nohome用户,默认没有nogroup组,需创建该组。

[root@localhost proftpd]# cat /etc/passwd | grep ftp
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
ftp01:x:507:100:ftpsvruser01:/home/ftp01:/sbin/nologin
ftp02:x:508:100:ftpsvruser01:/home/ftp02:/sbin/nologin
ftp03:x:509:100:ftpsvruser01:/home/ftp03:/sbin/nologin

主要的配置在./etc/proftpd.conf上

<VirtualHost IP>

......

</VirtualHost>

<Anonymous  "路径名" >  
.....
</Anonymous>
<Directory "路径名"OR Incoming>
...
</Directory>#关于匿名用户的设置
<Limit 限制动作>
..
</Limit>

<Directory >是对目录的访问权限控制,<Limit>是进行一些限制

网上配置很多,我这里只想说明点是:

默认匿名访问只有一个,但用VirtualHost可以用port来设置多个。或多个IP。

虚拟ftp一般用于一台ftp服务器有好多ip地址,或者ftp用不同的端口。

即<Anonymous  "路径名" >  
.....
</Anonymous>

虚拟路径可以有多个,附件conf里有VirtualHost配置实例,conf是我的应用系统配置实例,当然有写用户名改了而已。

配置前调试:[root@localhost proftpd]# ./sbin/proftpd -t  检测conf文件语法错误

[root@localhost proftpd]# ./sbin/proftpd -n  实时stderr,便于调试配置。-c 是配置文件调用。

 网上有将proftpd注册为services或xinet启动的脚本和方法,我不罗嗦了,search吧。

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot /home/ftp/ftp01 ftp01
DefaultRoot /home/ftp/ftp02 ftp02
DefaultRoot /home/ftp/ftp03 ftp03
DefaultChdir /home/ftp/ftp01
DefaultChdir /home/ftp/ftp02
DefaultChdir /home/ftp/ftp03
这几个设置的含义是:用ftp01登录,会自动跳到/home/ftp/ftp01目录下,proftpd默认是跳到/home/$user 用户的家目录下

但只有一个起作用,即ftp02、ftp03都会跳转到/home/ftp/ftp01下,那如何要ftp02自动跳转到/home/ftp/ftp02下呢,用VirtualHost,配置实例在conf附件里就不多写了。

匿名登录:

关键的语句:RequireValidShell    off  

在<Anonymous  "路径名" >里没有这句会匿名登录不成功。

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous /home/ftp/anon>
  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
  MaxClients            20

  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
  DisplayLogin            welcome.msg
  DisplayChdir            .message
  AnonRequirePassword    off
# 必须要如下项,不然匿名无法登录
  RequireValidShell    off
  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE>
    AllowAll
  </Limit>
  
  <Limit STOR>
    AlLowALL
  </Limit>
  
  <Limit DELE>
    AllowALl
   </Limit>

  <Limit LOGIN /home/ftp/anon>
   AllowALL
  </Limit>    
</Anonymous>

有用的几个命令:

ftpshut:关闭FTP服务,并在/etc下生成文件shutmsg。要重新开放FTP服务,把/etc/shutmsg删除。
2、ftpcout:FTP服务器在线人数信息显示。
3、ftpwho:FTP服务器在线人员名单

4、./sbin/ftpshut
这个命令还是比较实用的,因为你可能需要不断的调整你的服务器,而这个命令就非常灵活,可以在不停止proftpd进程的前提下,定时停止ftp连接

ftpshut [ -l min ] [ -d min ] time [ warning-message ... ]


-l min: 在ftp关闭服务之前的几分钟内,尝试建立新的ftp连接均不被接受
-d min: 在ftp关闭服务之前的几分钟内,已经建立的ftp连接将被中止
time: 在多少时间后,服务器将关闭ftp服务,格式有两种
+number 经过number分钟后关闭
MMHH 在今天MM:HH服务器将关闭

注意,这里我们用这个命令是把ftp服务给停了,但实际的proftpd进程还没停止,所以一般调试ftp会使用到这个命令。


举例:
再经过30分钟后,FTP服务将关闭,在这之前的20分钟不可接受任何新的ftp连接,已经建立的在服务关闭前10分钟强制断线,并在客户端显示“FTP Server Will shutdown at time”

ftpshut -l 20 -d 10 +30 "FTP Server Will shutdown at time"

.ftpaccess 文件

文档说如同apache的.htacess,就是在ftpsvr的目录下,建立一个.ftpaccess的文件,默认隐藏。作用如同proftpd.conf配置文件里一样的配置效果。用户认证后对目录权限的访问会首先访问.ftpaccess,再访问proftpd.conf的配置。下面的英文说的很清楚。

.ftpaccess files
.ftpaccess file is meant to function like Apache's .htaccess file: a file that acts as free-floating section of the server's configuration file. If a .ftpaccess file is present in a directory in which the server looks, it will parse that .ftpaccess file as a configuration file, and act accordingly. Only some configuration directives are allowed in the .ftpaccess context, though. The advantage of having this capability is that users can customize how the server treats directories that are under the user's control via files placed in those directories, instead of allowing the user to modify the main server configuration file itself. The disadvantage is that a user is capable of possibly overriding a configuration value that was set in the main configuration file for a specific purpose.

The server treats a directory that contains a .ftpaccess file exactly as if the configuration directives in that file had been placed in a <Directory> section in the main proftpd.conf file. For example, if there is a /home/users/bob directory on your system, and in that directory there was a .ftpaccess file that contained:

DirFakeUser on ~
DirFakeGroup on ~
Umask 0077

it would be treated exactly as if:

  <Directory /home/users/bob>
    DirFakeUser on ~
    DirFakeGroup on ~
    Umask 0077
  </Directory>

was written into

proftpd.conf

.

 

<Limit>的一些option

CMD:Change Working Directory 改变目录
MKD:MaKe Directory 建立目录的权限
RNFR: ReName FRom 更改目录名的权限
DELE:DELEte 删除文件的权限
RMD:ReMove Directory 删除目录的权限
RETR:RETRieve 从服务端下载到客户端的权限
STOR:STORe 从客户端上传到服务端的权限
READ:可读的权限,不包括列目录的权限,相当于RETR,STAT等
WRITE:写文件或者目录的权限,包括MKD和RMD
DIRS:是否允许列目录,相当于LIST,NLST等权限,还是比较实用的
ALL:所有权限
LOGIN:是否允许登陆的权限针对这些设置,又有如下具体的配置:AllowUser 针对某个用户允许的Limit
DenyUser 针对某个用户禁止的Limit
AllowGroup 针对某个用户组允许的Limit
DenyGroup 针对某个用户组禁止的Limit
AllowAll 针对所有用户组允许的Limit
DenyAll 针对所有用户禁止的Limit同时,可以针对单独的用户来限制速度TransferRate STOR|RETR 速度(Kbytes/s) user 使用者

变量内容:
%T 目前的时间
%F 所在硬盘剩下的内容
%C 目前所在目录
%R Client端的主机名称
%L Server端的主机名称
%U 使用者帐号名称
%M 最大允许联机人数
%N 目前的主机联机人数
%E FTP主机管理员email
%i 本次上传的档案数目
%o 本次下载的档案数量
%t 本次上传+下载的档案数量

网上说<Limit LOGIN>是一个用来限制登陆的特殊命令,在<limit>中用这个,可以禁止或者允许连接进来。但是,如果不在Server config,<VirtualHost> 或者<Anonymous>中使用的话,他将失去效用,或者说被忽略掉(比如在<Directory>中使用就是无效的),确实是这样的。

http://miaomiao7988.blogcn.com/articles/proftpd%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0.html 、

这个页面可供大家了解,如果大家对字符配置不熟,可先配置gproftpd,图形界面的,配置完后,再看配置文件,就学得比较快了

就不截图了,太懒了,文档和conf文件在附件里。



      本文转自fuhaixiong 51CTO博客,原文链接:http://blog.51cto.com/heliy/185565,如需转载请自行联系原作者




相关文章
|
Shell 数据安全/隐私保护
|
网络协议 安全 网络安全
|
监控 关系型数据库 MySQL
zabbix4.0安装配置及使用
zabbix4.0安装配置及使用
5847 0
|
监控 关系型数据库 应用服务中间件
|
监控 测试技术 Linux
|
存储 PHP 关系型数据库