搭建 CentOS 6 服务器(11) - vsftpd、ProFTPD

(一)vsftpd

安装
# yum -y install vsftpd
    Installed:
      vsftpd.i686 0:2.2.2-12.el6_5.1


设置
# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.backup
# vi /etc/vsftpd/vsftpd.conf
    # 不允许匿名用户登录
    anonymous_enable=NO
    # 设置空闲时间
    idle_session_timeout=300
    # 设置链接超时时间
    data_connection_timeout=30
    # 允许上传下载
    ascii_upload_enable=YES
    ascii_download_enable=YES
    # 登陆后的欢迎词
    ftpd_banner=Welcome to Myvsftpd FTP service.
    # 不允许一般用户访问上层文件夹
    chroot_local_user=YES
    chroot_list_enable=YES
    # 可以访问上层文件夹的用户一览
    chroot_list_file=/etc/vsftpd/chroot_list
    # 允许删除文件夹
    ls_recurse_enable=YES
    # 只允许「/etc/vsftpd/user_list」内的用户访问
    userlist_enable=NO


用户设置
# vi /etc/vsftpd/chroot_list
    root
# /usr/sbin/useradd ftpuser1 -d /home/ftpuser1 -G nobody
# passwd ftpuser1
    New password: 123456
    Retype new password: 123456
    passwd: all authentication tokens updated successfully.
# vi /etc/vsftpd/user_list
    ftpuser1
# vi /etc/hosts.allow
    vsftpd : 192.168.21. 127.0.0.1
# vi /etc/hosts.deny
    vsftpd : ALL


启动服务
# /etc/rc.d/init.d/vsftpd start


(二)ProFTPD

下载安装
# cd /usr/local/src
# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.5.tar.gz
# tar xvfz proftpd-1.3.5.tar.gz
# cd proftpd-1.3.5
# ./configure --enable-nls --prefix=/usr/local/proftpd
# make
# make install


创建用户
# cd /usr/local/proftpd/bin
# /usr/sbin/useradd ftpuser1 -d /home/ftpuser1 -G nobody
# passwd ftpuser1
    New password: 123456
    Retype new password: 123456
    passwd: all authentication tokens updated successfully.


做成私有密码文件
# id ftpuser1
# ./ftpasswd --passwd --file=/usr/local/proftpd/etc/ftpd.passwd --name=ftpuser1 \
  --uid=502 --gid=502 --home=/home/ftpuser1 --shell=/bin/bash
    ftpasswd: using alternate file: /usr/local/proftpd/etc/ftpd.passwd
    ftpasswd: creating passwd entry for user ftpuser1

    Password:111111
    Re-type password:111111

    ftpasswd: entry created
# ./ftpasswd --group --file=/usr/local/proftpd/etc/ftpd.group \
  --name=ftpuser1 --gid=502
    ftpasswd: using alternate file: /usr/local/proftpd/etc/ftpd.group
    ftpasswd: creating group entry for group ftpuser1
    ftpasswd: entry created


设置
# cp /usr/local/proftpd/etc/proftpd.conf /usr/local/proftpd/etc/proftpd.conf.bak
vi /usr/local/proftpd/etc/proftpd.conf
    ServerName "Welcome to MyProFTPD FTP service."
    Group nobody
    DefaultRoot ~
    注释掉「<Anonymous ~ftp>」 到 「</Anonymous>」
    ExtendedLog /var/log/proftp.log all

    <Directory />
      HideFiles ^\..*
    </Directory>

    AuthUserFile                    /usr/local/proftpd/etc/ftpd.passwd
    AuthGroupFile                   /usr/local/proftpd/etc/ftpd.group
    AuthOrder                       mod_auth_file.c

    MaxClientsPerHost 2 
    MaxClients 20

    PathAllowFilter \.(jpg|gif|png|jpeg)$
    MaxStoreFileSize 3 Mb

    ListOptions -a maxfiles 1000


启动脚本
# cd /usr/local/src/proftpd-1.3.5/contrib/dist/rpm
# cp proftpd.init.d /etc/init.d/proftpd
# vi /etc/init.d/proftpd
# chmod +x /etc/init.d/proftpd


启动服务
# /etc/init.d/proftpd start


FTP确认测试
C:\Documents and Settings\RenSanNing>ftp

连接
ftp> op
To 192.168.21.xxx
Connected to 192.168.21.xxx.
220 Welcome to MyProFTPD FTP service.
User (192.168.21.xxx:(none)): ftpuser1
331 Please specify the password.
Password:
230 Login successful.

变更文件夹
ftp> pwd
257 "/"
ftp> cd /root/
550 Failed to change directory.
ftp> cd /etc/
550 Failed to change directory.

上传文件
ftp> put c:\test.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 7 bytes sent in 0.00Seconds 7000.00Kbytes/sec.

确认文件
ftp> ls -l
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 503      503             7 Aug 20 11:51 test.txt
226 Directory send OK.
ftp: 66 bytes received in 0.00Seconds 66000.00Kbytes/sec.

下载文件
ftp> get test.txt
200 PORT command successful. Consider using PASV.
150 Opening ASCII mode data connection for test.txt (7 bytes).
226 Transfer complete.
ftp: 7 bytes received in 0.00Seconds 7000.00Kbytes/sec.

ftp> bye
221 Goodbye.

客户端工具:
FFFTP: http://sourceforge.jp/projects/ffftp/
FileZilla: https://filezilla-project.org/

你可能感兴趣的:(centos)