Proftpd 搭建FTP笔记

来源:互联网 发布:怎么完成淘宝开店认证 编辑:程序博客网 时间:2024/04/24 20:52
Proftpd 搭建FTP笔记
一、初学Linux,想用它来架设个FTP,对于初学者来说,可谓是困难重重,经过参考网上的各种资料,再结合自己的试验,终于搞定了Proftpd来架设FTP,和开设虚拟目录了,下面来记录整个过程,希望对新手是个帮助.
二、配置要求:
1、建三个用户,FTP根目录为/var/ftp
2、tc为/var/ftp总目录登录用户
3、he为/var/ftp/he目录登录用户
4、ktm为/var/ftp/ktm目录登录用户
5、因用户需要对自己目录的所有文件具体有可操作性,所以不限制操作权限.
6、关掉匿名登录
三、安装过程
1、安装Proftpd软件,从网上下载proftpd-1.3.1.tar.gz,上传到安装目录/opt
# tar zxvf proftpd-1.3.1.tar.gz       解压proftpd-1.3.1
# cd proftpd-1.3.1.tar.gz             进入proftpd-1.3.1目录
# ./configure --prefix=/etc/proftpd     把proftpd-1.3.1安装到/etc/proftpd文件夹下
# make
# make install
2、新建tc he ktm用户
# groupadd he
# groupadd ktm
# mkdir -p /var/ftp/he
# mkdir /var/ftp/ktm
# useradd he –g he –d /var/ftp/he –s /sbin/nologin
# useradd ktm –g ktm –d /var/ftp/ktm –s /sbin/nologin  新建he用户,并加入he用户组,目录建立在/var/ftp下,并指定它的shell为noligin。
# passwd he 设密码为:he
# passwd ktm 设密码为:ktm
# useradd -d /var/ftp tc  添加tc用户,把目录建立在/var/ftp下。
# passwd tc  设置密码为: tc
# chown tc.tc /var/ftp
# chown he.he /var/ftp/he
# chown ktm.ktm /var/ftp/ktm
# chmod -R 777 /var/ftp
# chmod -R 775 /var/ftp/he
# chmod -R 775 /var/ftp/ktm
3、权限设置完成,下面配置文件。
#cp /opt/proftpd-1.3.1/contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd  拷贝proftpd.init.d到启动目录/etc/rc.d/init.d/并更名为proftpd
# vi /etc/rc.d/init.d/proftpd  编辑proftpd
/PATH找到PATH,按I,更改为:PATH="$PATH:/etc/proftpd/sbin:/etc/proftpd/bin"
:x保存退出.
# chmod +x /etc/rc.d/init.d/proftpd 改写proftpd为可执行.
# chkconfig -–add proftpd 把proftpd加入服务
# vi /etc/proftpd/etc/proftpd.conf
找到:User    nobody
     Group    nogroup
把nogroup改为nobody
# service proftpd start (stop) 启动 proftpd
配置完成,现在可以用ftp登录软件来测试下登录,匿名登录.
是不是速度很慢,没关系,打开
#vi /etc/proftpd/etc/proftpd.conf
在最后加入:
UseReverseDNS off
IdentLookups off
这样登录FTP就会快了。
四、配置虚拟目录
1、禁止匿名登录
更改DefaultRoot ~ 为:  DefaultRoot /var/ftp
找到:
# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<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
#  MaxClients   10
  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
#  DisplayLogin   welcome.msg
#  DisplayChdir   .message
  # Limit WRITE everywhere in the anonymous chroot
#  <Limit WRITE>
#    DenyAll
#  </Limit>
#</Anonymous>
把这一段全部屏蔽。
找到:
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>
把这一段全部打开,允许chmod
找到:
AllowOverwrite  on
在下面添加:
AllowRetrieveRestart   on  
AllowStoreRestart      on

<Anonymous ~he>
User he
Group nobody
<Directory /var/ftp/he>
<Limit SITE_CHMOD>
#DenyUser skate
AllowAll
</Limit>
</Directory>
</Anonymous>
<Anonymous ~ktm>
User ktm
Group nobody
<Directory /var/ftp/ktm>
<Limit SITE_CHMOD>
#DenyUser ktm
AllowAll
</Limit>
</Directory>
</Anonymous>

# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>
增加断点续传功能:
AllowOverwrite    on
AllowRetrieveRestart   on  #支持下载断点续传,默认就支持
AllowStoreRestart      on    #支持上传断点续传,默认不支持
保存后重启下服务,用各个用户登录测试下吧。
整个文件为:
# 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   "ProFTPD Default Installation"
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 limit maximum number of processes per service
# (such as xinetd).
MaxInstances   30
# Set the user and group under which the server will run.
User    nobody
Group    nobody
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot /var/ftp
# Normally, we want files to be overwriteable.
  AllowRetrieveRestart   on   
  AllowOverwrite   on   
  AllowStoreRestart   on  
<Anonymous ~tc>
User tc
Group nobody
<Directory /var/ftp>
<Limit SITE_CHMOD>
#DenyUser tc
AllowAll
</Limit>
  AllowRetrieveRestart   on   
  AllowOverwrite   on   
  AllowStoreRestart   on  
</Directory>
</Anonymous>
<Anonymous ~he>
User he
Group nobody
<Directory /var/ftp/he>
<Limit SITE_CHMOD>
#DenyUser skate
AllowAll
</Limit>
  AllowRetrieveRestart   on   
  AllowOverwrite   on   
  AllowStoreRestart   on  
</Directory>
</Anonymous>
<Anonymous ~ktm>
User ktm
Group nobody
<Directory /var/ftp/ktm>
<Limit SITE_CHMOD>
#DenyUser ktm
AllowAll
</Limit>
  AllowRetrieveRestart   on   
  AllowOverwrite    on   
  AllowStoreRestart   on  
</Directory>
</Anonymous>

# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>
# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<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
#  MaxClients   10
  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
#  DisplayLogin   welcome.msg
#  DisplayChdir   .message
  # Limit WRITE everywhere in the anonymous chroot
#  <Limit WRITE>
#    DenyAll
#  </Limit>
#</Anonymous>
UseReverseDNS off
IdentLookups off
原创粉丝点击