用Proftpd构建Ttp服务器
创始人
2024-07-21 16:40:25
0

proftpd构建ftp服务器:

  FTP服务被广泛的应用着,常见的,一些大学、组织、机构等等,都有通过FTP服务器向外发布数据…但在这里,我们将要构建的FTP服务器将主要针对 用于用户更新自己的网站。也就是说,让用户(root除外)只可以访问自己的Web目录(本站前面介绍的HTTP服务器构建中以public_html为 例)。

  另外,为了避免通过平文传输时,数据被截获,从而泄漏隐私与密码,我们采用TLS方式,加密FTP传输过程中的数据,以确保安全。

  (构建FTP服务器,您将有多种选择,比如通过vsftpd等等FTP服务器软件。但ProFTPD在一些方面,更能够符合我们的实际条件,尤其对于ADSL方式接入网络的服务器,ProFTPD能够很好的应对不断变化的IP地址造成的问题。)

  安装 ProFTPD

  由于ProFTPD不存在于CentOS中yum的官方库中,所以用yum安装ProFTPD需要定义非官方的库。请先确认相应非官方库文件的存在。

  1.   [root@sample ~]# ls -l /etc/yum.repos.d/dag.repo  ← 确认相应库文件的存在性  
  2.  
  3.   -rw-r--r-- 1 root root 143 Oct 1 21:33 /etc/yum.repos.d/dag.repo ← 确认其存在(否则不能通过yum安装ProFTPD)  
  4.  

  如果以上,dag.repo文件不存在,则不能通过yum安装ProFTPD,需要定义非官方库。定义非官方库的方法请见 “CentOS的下载、安装及初始环境设置”一节中yum的相关设置。而且,在此前提下也要保证所定义的dag.repo文件的语法的正确性。

  然后,通过yum来在线安装ProFTPD。

  1.   [root@sample ~]# yum -y install proftpd  ← 安装ProFTPD  
  2.  
  3.   Setting up Install Process  
  4.  
  5.   Setting up repositories  
  6.  
  7.   Reading repository metadata in from local files  
  8.  
  9.   Reducing Dag RPM Repository for Red Hat Enterprise Linux to included packages only  
  10.  
  11.   Finished  
  12.  
  13.   Parsing package install arguments  
  14.  
  15.   Resolving Dependencies  
  16.  
  17.   --> Populating transaction set with selected packages. Please wait.  
  18.  
  19.   ---> Downloading header for proftpd to pack into transaction set.  
  20.  
  21.   proftpd-1.2.10-10.2.el4.r 100% |=========================| 15 kB 00:00  
  22.  
  23.   ---> Package proftpd.i386 0:1.2.10-10.2.el4.rf set to be updated  
  24.  
  25.   --> Running transaction check  
  26.  
  27.   Dependencies Resolved  
  28.  

  =============================================================================

  1.   Package Arch Version Repository Size  
  2.  

  =============================================================================

  1.   Installing:  
  2.  
  3.   proftpd i386 1.2.10-10.2.el4.rf dag 699 k  
  4.  
  5.   Transaction Summary  
  6.  

  =============================================================================

  1.   Install 1 Package(s)  
  2.  
  3.   Update 0 Package(s)  
  4.  
  5.   Remove 0 Package(s)  
  6.  
  7.   Total download size: 699 k  
  8.  
  9.   Downloading Packages:  
  10.  
  11.   (1/1): proftpd-1.2.10-10. 100% |=========================| 699 kB 00:03  
  12.  
  13.   Running Transaction Test  
  14.  
  15.   Finished Transaction Test  
  16.  
  17.   Transaction Test Succeeded  
  18.  
  19.   Running Transaction  
  20.  
  21.   Installing: proftpd ######################### [1/1]  
  22.  
  23.   Installed: proftpd.i386 0:1.2.10-10.2.el4.rf  
  24.  
  25.   Complete!  
  26.  

#p#

  配置 ProFTPD

  然后,通过修改相应配置文件配置ProFTPD。

  1.   [root@sample ~]# vi /etc/proftpd.conf  ← 修改ProFTPD的配置文件  
  2.  
  3.   ServerType        standalone   ← 找到这一行,在行首添加“#”  
  4.  
  5.   ↓  
  6.  
  7.   #ServerType        standalone   ← 变为此状态,不使用常驻模式  
  8.  
  9.   #ServerType       inetd   ← 找到这一行,去掉行首的“#”  
  10.  
  11.   ↓  
  12.  
  13.   ServerType       inetd   ← 变为此状态,通过超级服务器来启动ProFTPD  
  14.  
  15.   DefaultRoot        ~ !adm   ← 找到这一行,将“ !adm”改为“/public_html !wheel”  
  16.  
  17.   ↓  
  18.  
  19.   DefaultRoot        ~/public_html !wheel   ← 变为此状态,使除wheel组用户的根目录为public_html  
  20.  

  找到TLS设置的语句群,如下:

  1.   # TLS  
  2.  
  3.   # Explained at http://www.castaglia.org/proftpd/modules/mod_tls.html  
  4.  

  ----------------------------------------------------------------

  1.   #TLSEngine         on  
  2.  
  3.   #TLSRequired        on  
  4.  
  5.   #TLSRSACertificateFile   /usr/share/ssl/certs/proftpd.pem  
  6.  
  7.   #TLSRSACertificateKeyFile /usr/share/ssl/certs/proftpd.pem  
  8.  
  9.   #TLSCipherSuite      ALL:!ADH:!DES  
  10.  
  11.   #TLSOptions        NoCertRequest  
  12.  
  13.   #TLSVerifyClient       off  
  14.  
  15.   ##TLSRenegotiate     ctrl 3600 data 512000 required off timeout 300  
  16.  
  17.   #TLSLog           /var/log/proftpd/tls.log  
  18.  

  ----------------------------------------------------------------

  ↓将以上水平线间部分的语句,每行行首的“#”都去掉,变为下面水平线间的状态:

  ----------------------------------------------------------------

  1.   TLSEngine          on  
  2.  
  3.   TLSRequired         on  ← 只允许TLS方式的连接(如果将on改为off,普通方式也被允许)  
  4.  
  5.   TLSRSACertificateFile    /usr/share/ssl/certs/proftpd.pem  
  6.  
  7.   TLSRSACertificateKeyFile  /usr/share/ssl/certs/proftpd.pem  
  8.  
  9.   TLSCipherSuite       ALL:!ADH:!DES  
  10.  
  11.   TLSOptions         NoCertRequest  
  12.  
  13.   TLSVerifyClient       off  
  14.  
  15.   #TLSRenegotiate      ctrl 3600 data 512000 required off timeout 300  
  16.  
  17.   TLSLog            /var/log/proftpd/tls.log  
  18.  

  ----------------------------------------------------------------

  然后在配置文件的末尾填如下几行:

  1.   ExtendedLog        /var/log/proftpd/access.log WRITE,READ default  ← 记录连接日志到相应日志文件  
  2.  
  3.   ExtendedLog        /var/log/proftpd/auth.log AUTH auth  ← 记录认证日志到相应日志文件  
  4.  
  5.   MasqueradeAddress    digeast.no-ip.info  ← 定义服务器域名  
  6.  
  7.   PassivePorts        50000 50030  ← 为PASV模式连接时指定端口号(1024以后存在的任意端口号)  
  8.  
  9.   然后,为服务器建立证书。  
  10.  
  11.   [root@sample ~]# cd /usr/share/ssl/certs  ← 进入相应的目录  
  12.  
  13.   [root@sample certs]# make proftpd.pem  ← 建立服务器证书  
  14.  
  15.   umask 77 ; \  
  16.  
  17.   PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \  
  18.  
  19.   PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \  
  20.  
  21.   /usr/bin/openssl req -newkey rsa:1024 -keyout $PEM1 -nodes -x509 -days 365 -out $PEM2 ; \  
  22.  
  23.   cat $PEM1 > proftpd.pem ; \  
  24.  
  25.   echo "" >> proftpd.pem ; \  
  26.  
  27.   cat $PEM2 >> proftpd.pem ; \  
  28.  
  29.   rm -f $PEM1 $PEM2  
  30.  
  31.   Generating a 1024 bit RSA private key  
  32.  
  33.   .........++++++  
  34.  
  35.   ............++++++  
  36.  
  37.   writing new private key to '/tmp/openssl.sG3126'  
  38.  

  -----

  1.   Country Name (2 letter code) [GB]:CN  ← 输入国家简写  
  2.  
  3.   State or Province Name (full name) [Berkshire]:Hei Long Jiang  ← 输入省份  
  4.  
  5.   Locality Name (eg, city) [Newbury]:Harbin  ← 输入城市  
  6.  
  7.   Organization Name (eg, company) [My Company Ltd]:www.centospub.com  ← 输入组织名(任意)  
  8.  
  9.   Organizational Unit Name (eg, section) []:  ← 直接回车跳过  
  10.  
  11.   Common Name (eg, your name or your server's hostname) []:www.centospub.com   ← FTP服务器名反馈  
  12.  
  13.   Email Address []:yourname@yourserver.com  ← 输入E-mail地址  
  14.  

#p#

  启动 ProFTPD

  启动之前,先对超级服务器的ProFTPD的启动脚本做一些修改。

  1.   [root@sample certs]# vi /etc/xinetd.d/xproftpd  ← 编辑ProFTPD启动脚本  
  2.  
  3.   log_on_success += DURATION USERID  ← 找到此行,将“DURATION USERID”改为“HOST PID”  
  4.  
  5.   ↓  
  6.  
  7.   log_on_success += HOST PID   ← 变为此状态,防止登录时要等待30秒  
  8.  
  9.   log_on_failure += USERID  ← 找到此行,将“USERID”改为“HOST”  
  10.  
  11.   ↓  
  12.  
  13.   log_on_failure += HOST   ← 变为此状态,防止登录时要等待30秒  
  14.  
  15.   disable = yes  ← 找到此行,将yes改为no  
  16.  
  17.   ↓  
  18.  
  19.   disable = no   ← 变为此状态,让ProFTPD通过超级服务器启动  
  20.  

  然后,通过重新启动超级服务器间接启动ProFTPD。

  1.   [root@sample certs]# chkconfig xproftpd on  ← 设置ProFTPD自启动  
  2.  
  3.   [root@sample certs]# chkconfig --list xproftpd  ← 查看ProFTPD自启动  
  4.  
  5.   xproftpd on  ← 确认为on的状态就OK  
  6.  
  7.   [root@sample certs]# /etc/rc.d/init.d/xinetd restart  ← 重新启动超级服务器  
  8.  
  9.   Stopping xinetd:                [ OK ]  
  10.  
  11.   Starting xinetd:                 [ OK ]  
  12.  

  连接到FTP服务器

  当我们成功的启动了FTP服务之后,就可以通过客户端软件连接到服务器进行文件的上传和下载了。但由于,本站介绍的方法,把安全、传输的保密性放在了 ***位,这也就使得好多不支持TSL的FTP软件无法连接到服务器。支持TSL的FTP客户端软件,比较有代表性的有Staff-FTP, SmartFTP。本站将以SmartFTP为例(下一节),介绍如何从客户端通过FTP连接到服务器的方法。

【编辑推荐】

  1. 用MySQL和Proftpd配置FTP服务器
  2. ProFTPD 下的五大问题
  3. Linux ProFTPd服务器配置(全)
  4. ProFTPD的配置文件proftpd.conf
  5. ProFTPD的启动与测试
  6. 手把手教你 配置ProFTPD服务器
  7. ProFTPd的启动
  8. 在图形界面下控制ProFTPD

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...
2012年第四季度互联网状况报... [[71653]]  北京时间4月25日消息,据国外媒体报道,全球知名的云平台公司Akamai Te...