Ubuntu 10.10 server 实践–ftp proftp安装

十二 09 2010

今天晚上安装了ftp服务程序,我们选择proftp,首先源码下载到windows,网站http://www.proftpd.org/, 我下载的软件包为proftpd-1.3.3c.tar.gz,接下来通过昨天的方法,利用xshell把windows的源码包传到linux上,源码安装需要gcc支持,请确认系统已经安装gcc编译器,接下来具体操作步骤:

$sftp username@ip
$>put local_file remote_dir  #(> put D:proftpd-1.3.3c.tar.gz  /home/software/)
$>quit
$ssh username@ip
$cd /home/software
$tar -xzvf /home/software/proftpd-1.3.3c.tar.gz -C /home/lib
$cd /home/lib/proftpd-1.3.3c
$sudo ./configure --prefix=/usr/local/proftp
$sudo make
$sudo make install

接下来修改/usr/local/proftp/etc/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                      "ProFTPD Default Installation"
ServerType                      standalone
DefaultServer                   on

# Port 21 is the standard FTP port.
Port                            21

# Don't use IPv6 support by default.
UseIPv6                         off

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

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.
AllowOverwrite          on
SystemLog   /usr/local/proftp/log/proftpd.log

# 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>
# user access config file path
AuthUserFile /usr/local/lib/proftp/etc/passwd
# change the auth file order
AuthOrder mod_auth_file.c mod_auth_unix.c

配置文件中我们已经配置权限验证通过文件方式。接下来我们参照http://www.proftpd.org/docs/contrib/ftpasswd.html来配置添加ftp用户。我们用到也就是

ftpasswd --passwd --name=bob--uid=1001 --file=/usr/local/lib/proftp/etc/passwd --home=/home/bob --shell=/bin/false

会提示你输入密码,输入密码后就会生成一个用户密码配置文件,路径如下: /usr/local/lib/proftp/etc/passwd,如果你不知道怎么获取uid,那么请用下面的命令查看,那个显示的数字就是了

id nobody

现在如果你启动proftp可能出现总是登录不上的情况,解决办法就是在/etc/shells 添加一行 /bin/false

最后启动你的proftp,

$sudo /usr/local/lib/proftp/sbin/proftpd

那么整个ftp就成功了,如果发生错误请查看日志文件,路径我们配置文件中也配置了 /usr/local/proftp/log/proftpd.log
如果是端口占用,请用下面命令查看是什么进程占用了

$sudo netstat -pant

查到占用21端口的进程,你可以kill,还可以更改配置文件的端口来解决这个问题。
如果你的proftp不是系统service,怎么停掉呢,方法很简单

$ps aux|grep "proftpd"
$kill id

那个/usr/local/proftp/sbin/ftpshut 命令是不能完全停止进程的,会一直占用21端口,这种停止只能让ftp用户没有办法登录。

One response so far

  1. Ubuntu Server 方面,貌似没有一套完整的 ProFTP 使用指南,都是胡拼乱凑

Leave a Reply

*