建立ftp SERVER Using proftpd

tar -jxvf /root/tools/proftpd-1.3.12.tar.bz2
./configure --prefix=/opt/proftpd1.3.2/
make
make install

 

 

2)启动proftpd
如果以standalone模式启动:
启动:/opt/proftpd1.3.2/sbin/proftpd
关闭:/opt/proftpd1.3.2/sbin/ftpshut now
或者用以下方式:
     cp proftpd-1.3.2/contrib/dist/rpm/proftpd.init.d /etc/init.d/proftpd
         vi /etc/init.d/proftpd
     修改PATH的值,使其如右: PATH="$PATH:/opt/proftpd1.3.2/sbin"
     chmod +x /etc/init.d/proftpd
     service proftpd start/stop/restart

如果是以super daemon方式启动:
vi /etc/xinetd.d/proftpd
service ftp
{
  disable        = no
       flags           = REUSE
       socket_type     = stream
       wait            = no
       user            = root
       server         = /opt/proftpd1.3.2/sbin/proftpd
       server_args     = -c /opt/proftpd1.3.2/etc/proftpd.conf
       log_on_success  += DURATION USERID
       log_on_failure  += USERID
}
service xinetd restart

3)配置

 

添加ftp group 和 ftp user

groupadd ftp

useradd -g ftp -s /bin/false  ftp

 

 

配置文件/opt/proftpd1.3.2/etc/proftpd.conf

#基本设置:
#當使用者登入主機的時候,proftpd 會顯示在 Client端显示的信#當使用者登入主機的時候,proftpd 會顯示在 Client端显 示的信息)
ServerName                      "My FTP Server"

# 如果以standalone模式启动,则启用第一行,这里是以 super daemon 啟動的,就启用第二行
ServerType          standalone
ServerType          inetd

# Port 21 is the standard FTP port.
Port                            21

#预设的目录与档案的属性
Umask                           022

#不充许root登入(default value is off)
RootLogin           off


# 這个设定可以讓使用者不需要具有『能夠執行的 shell 』!即使使用者无法用ssh,但依然可以使用 ftp !
RequireValidShell   off

#同一時間允許的連線數目
MaxInstances                    30


#最多僅允許 100 個 client登入我們主機
MaxClients              100


#同一個主機最多可以同時 5 個 FTP 連線
MaxClientsPerHost       5

#允許使用者上傳續傳!預設是 off
AllowStoreRestart       on


#預设的服务启动者!後面接的使用者與群組,必須在 /etc/passwd 與 /etc/group 裡面存在方可!
User                             nobody
Group                           nogroup


#这里设置DefaultRoot,ftpuser group 中 的用户只能访问自已的家目录.


DefaultRoot  ~ ftpusers

#允许根目录复写
<Directory />
AllowOverwrite      on
</Directory>

#限制用户使用chmod
<Limit SITE_CHMOD>
  DenyAll
</Limit>

#以下是ftpusers组的用户的设置,ftpusers组的家目录是/home/ftp,/home/ftp/download只能允许下载,/home/ftp/upload只能允许上传,具体设置如下:
<Directory /home/ftp/download>
<Limit RETR>
  AllowALL
</Limit>
<Limit WRITE>
  DenyALL
</Limit>
</Directory>

<Directory /home/ftp/upload>
<Limit STOR MKD>
  AllowALL
</Limit>
<Limit READ>
  DenyALL
</Limit>
</Directory>


#以下是匿名用户设置.匿名用户的根目录是/var/ftp.anonymous 登入后的身份= ftp:ftp 這个用户.
#/opt/ftp/download 只能允许下载,/var/ftp/upload只能允许上传,具体设置如下:
 <Anonymous /opt/ftp/>
  User              ftp
  Group             ftp
  UserAlias         anonymous ftp
  MaxClients            10
  DisplayLogin          welcome.msg
  DisplayFirstChdir     .message

  TransferRate STOR 100 user anonymous.ftp
  TransferRate RETR 50  user anonymous.ftp
  <Limit WRITE>
   DenyAll
  </Limit>
  <Directory download>
  <Limit RETR>
  AllowALL
  </Limit>
  <Limit WRITE>
  DenyALL
  </Limit>
  </Directory>

  <Directory upload>
  <Limit STOR MKD>
  AllowALL
  </Limit>
  <Limit READ>
  DenyALL
  </Limit>
  </Directory>
  </Anonymous>

4)配置说明:
        4.1)Limit可以限制的动作
                CMD:Change Working Directory 改变目录
                MKD:MaKe Directory 建立目录的权限
                RNFR: ReName FRom 更改目录名的权限
                DELE:DELEte 删除文件的权限
                RMD:ReMove Directory 删除目录的权限
                RETR:RETRieve 从服务端下载到客户端的权限
                STOR:STORe 从客户端上传到服务端的权限
                READ:可读的权限,不包括列目录的权限,包括RETR, SITE, SIZE, STAT
                WRITE:写文件或者目录的权限,包括APPE, DELE, MKD, RMD, RNTO, STOR, XMKD, XRMD
                DIRS:是否允许列目录,包括CDUP, CWD, LIST, MDTM, NLST, PWD, RNFR, XCUP, XCWD,XPWD

        针对上面这个Limit所应用的对象,又包括以下范围
                AllowUser 针对某个用户允许的Limit
                DenyUser 针对某个用户禁止的Limit
                AllowGroup 针对某个用户组允许的Limit
                DenyGroup 针对某个用户组禁止的Limit
                AllowAll 针对所有用户组允许的Limit
                DenyAll 针对所有用户禁止的Limit
        4.2)欢迎词里的变量解释
                %T 目前的时间
                %F 所在硬盘剩下的容量
                %C 目前所在的目录
                %R Client 端的主机名称
                %L Server 端的主机名称
                %U 使用者帐户名称
                %M 最大允许连接人数
                %N 目前的服务器连接人数
                %E FTP服务器管理员的 email
                %i 本次上传的文件数量
                %o 本次下载的文件数量
                %t 本次上传+下载的文件数量
        example:(welcome.msg)
                vi /var/ftp/welcome.msg
                歡迎光臨!
                我的主機: %L
                目前時間: %T
                最大連線: %M
                目前連線: %N
                您的主機: %R
                您的帳號: %U
                目前目錄: %C
        example:(some info)
                vi /var/ftp/upload/.message
                this directory is only for upload!
                you are anonymous!

        4.3)上传100Kbytes/second ,下载速度50Kbytes/second
                TransferRate  STOR    100  user anonymous,ftp
                TransferRate  RETR    50   user anonymous,ftp

 

FAQ

1、我安装proftpd以后,出现了问题,我如何调试? 

通过通过命令! /usr/local/sbin/proftpd -d9 -n启动proftpd来进行调试,则proftp d就会将
调试信息打印到consle上以供调试之用。 

2、为什么我的proftpf启动以后,匿名用户不能登录? 

        查看proftp配置文件/usr/local/etc/proftpd.conf,修改<Anonymous ~ftp>为
        <Anonymous /home/ftp>(这里/home/ftp可以是任何希望匿名用户登录以后的当前根目录,
        但是确保要使该目录允许ftp用户访问),并且若<Anonymous /home/ftp>部分的User指令
        指定的用户为ftp用户,则需要在配置文件中添加如下命令指示: 

                  RequireValidShell off 

3、我如何实现一个正常用户登录以后将其的访问限定在某个目录之下? 

可以通过指令DefaultRoot来实现。例如若希望将ftpusers组的用户限定在自己的home目录下,则
需要首先创建该组: 

/usr/sbin/groupadd ftpusers 

然后将用户ideal加入到该组中: 

usrmod -G ftpusers ideal 

最后在在proftpd.conf文件中添加如下内容: 

DefaultRoot ~ ftpusers 

也可以限制用户登录以后仅仅访问自己主目录下的一个子目录: 

DefaultRoot ~/anoftp ftpusers 

当然也可以将用户限制在其他目录之下,而不是自己的home目录下: 

DefaultRoot /tmp ftpusers 

也可以限定一个用户组的某些用户被限制,而其他不作限制: 

DefaultRoot ~ ftpusers,!empolyee 

这个指令指示仅仅限制ftpusers组中的不是empolyee组的用户进行限制。 

4、我如何使用户登陆时不显示ftp服务器版本信息,以增强安全性? 

在proftpd.conf中添加如下内容: 

ServerIdent off 

则再次登录时,显示如下内容: 

C:WINDOWS>ftp 192.168.2.33 
Connected to 192.168.2.33. 
220 ftpd.test.com.cn FTP server ready. 
User (192.168.2.33:(none)): 

5、在proftpd环境下如何设定虚拟主机? 

可以通过指令:VirtualHost来实现,一个最简单的例子: 

<VirtualHost 192.168.2.35> 
     ServerName "virtual FTP server" 
</VirtualHost> 


若你仅仅希望通过匿名访问某个虚拟主机,则使用如下指令: 

<VirtualHost 192.168.2.35>  

Serv erName "virtual FTP server"  

<Limit LOGIN>  
DenyAll  
</Limit>  

<Anonymous /usr/local/private>  

User private 
Group private  

<Limit LOGIN>  
AllowAll  
</Limit> 

</Anonymous>  

</VirtualHost> 

这样192.168.2.35的这台主机则仅仅允许匿名登录。 

笔者的proftpd.conf配置文件内容为: 

# This is a basic ProFTPD configuration file (rename it to 
# 'proftpd.conf' for actual use. It establishes a single server 
# and a single anonymous login. It assumes that you have a user/group 
# "nobody" and "ftp" for normal operation and anon. 

ServerName &! quot;test.com.cn FTP Server" 
ServerType standalone 
DefaultServer on 

# Port 21 is the standard FTP port. 
Port 21 
# Umask 022 is a good standard umask to prevent new dirs and files 
# from being group and world writable. 
Umask 022 

# To prevent DoS attacks, set the maximum number of child processes 
# to 30. If you need to allow more than 30 concurrent connections 
# at once, simply increase this value. Note that this ONLY works 
# in standalone mode, in inetd mode you should use an inetd server 
# that allows you to&! nbsp;limit maximum number of processes per&nb sp;service 
# (such as xinetd) 
MaxInstances 30 


RequireValidShell off 
ServerIdent off 


# Set the user and group that the server normally runs at. 
User nobody 
Group nobody 

# Normally, we want files to be overwriteable. 
<Directory /*> 
AllowOverwrite on 
</Directory> 

# A basic anonymous configuration, no upload directories. 
<Anonymous /home/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 
MaxClients 10 

# 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> 


DefaultRoot ~ ftpusers 

<VirtualHost 192.168.2.35>  

ServerName "virtual FTP server"  

<Limit LOGIN>  
DenyAll  
</Limit>  

<Anonymous /usr/local/private>  

User private 
Group private  

<Limit LOGIN>  
AllowAll  
</Limit> 

</Anonymous>  

</VirtualHost> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值