设为首页 收藏本站
查看: 717|回复: 0

在LINUX系统上建立FTP加密传输

[复制链接]

尚未签到

发表于 2015-5-29 09:16:42 | 显示全部楼层 |阅读模式
在众多的FTP服务器中PROFTPD由于它的配置灵活,安装简便。近年来一直受到人们的喜爱。通常情况下FTP包括认证过程,传输是明文传输的,在传输一些敏感数据时总是不能让人放心。今天我在网上找了一些零散的资料结合自己的实作写了个帖子贡献给大家。

下载最新的软件版本:

# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.0rc3.tar.gz

首先创建ROFTPD运行的用户和组:

# groupadd nogroup
# useradd –g nogroup –d /dev/null –s /sbin/nologin nobody

首先创建上传下载的用户和组:

# groupadd ftp
# useradd –g ftp –d /home/down –s /sbin/nologin down
# useradd –g ftp –d /home/upload –s /sbin/nologin upload
用户密码设置略

编译安装PROFRPD:

# tar –zxvf proftpd-1.3.0rc3.tar.gz
# cd proftpd-1.3.0rc3
# ./configure  
--prefix=/usr/local/proftpd  
--sysconfdir=/etc  
--enable-autoshadow  
--localstatedir=/var/run  
--enable-ctrls  
--with-modules=mod_tls

# make
# make install

配置PROFTPD服务器:

# vi /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                                      "llzqq"
ServerType                                      standalone
DefaultServer                                   on
AllowRetrieveRestart                            on
AllowStoreRestart                               on
ServerType                                      standalone
ServerIdent                                     on
SystemLog                                       /var/log/proftpd.log
UseReverseDNS                                   off
IdentLookups                                    off
RequireValidShell                               off
# 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
MaxInstances                                    100
# 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

# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin                                    .welcome
DisplayFirstChdir                               .message
# Limit User of being enbled login ftp server

AllowGroup ftp
DenyAll

#########################ssl/tls############################
# MOD_TLS SETTING

TLSEngine on
TLSLog /var/log/proftpd-tls.log
TLSProtocol SSLv23
# Are clients required to use FTP over TLS when talking to this server?
TLSRequired ctrl
# Server's certificate
TLSRSACertificateFile /etc/proftpd.crt
TLSRSACertificateKeyFile /etc/proftpd.key
# Authenticate clients that want to use FTP over TLS
TLSVerifyClient off
#########################ssl/tls############################


DenyGroup ftp

TransferRate RETR 150 group ftp



DenyGroup ftp

TransferRate STOR 150 group ftp

MaxClientsPerHost 200
PassivePorts 55000 56000
================+================+=================

创建PROFTPD的日志文件:

# touch /var/log/proftpd.log
# touch /var/log/proftpd-tls.log
# chown nobody:nogroup /var/log/proftpd.log /var/log/proftpd-tls.log

创建SSL传输的证书和密匙:

# cp /usr/share/ssl/openssl.cnf ./
# openssl req -new -x509 -nodes -config openssl.cnf -out proftpd.crt –keyout  proftpd.key
这里安装提示需要输入证书信息略

把证书和密匙复制到指定目录:
# cp proftpd.crt proftpd.key /etc/
  最后创建PROFTPD启动教本:

# vi /etc/init.d/proftpd
================+================+=================
#!/bin/sh
# Startup script for ProFTPD
# chkconfig: 345 85 15
# description: ProFTPD is an enhanced FTP server
# processname: proftpd
# config: /etc/proftpd.conf
# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/proftpd ]; then
      . /etc/sysconfig/proftpd
fi
PATH="$PATH:/usr/local/proftpd/sbin"
# See how we were called.
case "$1" in
        start)
                echo -n "Starting proftpd: "
                daemon proftpd $OPTIONS
                echo
                touch /var/lock/subsys/proftpd
                ;;
        stop)
                echo -n "Shutting down proftpd: "
                killproc proftpd
                echo
                rm -f /var/lock/subsys/proftpd
                ;;
        status)
                status proftpd
                ;;
        restart)
                $0 stop
                $0 start
                ;;
        reread)
                echo -n "Re-reading proftpd config: "
                killproc proftpd -HUP
                echo
                ;;
        suspend)
                hash ftpshut >/dev/null 2>&1
                if [ $? = 0 ]; then
                        if [ $# -gt 1 ]; then
                                shift
                                echo -n "Suspending with '$*' "
                                ftpshut $*
                        else
                                echo -n "Suspending NOW "
                                ftpshut now "Maintanance in progress"
                        fi
                else
                        echo -n "No way to suspend "
                fi
                echo
                ;;
        resume)
                if [ -f /etc/shutmsg ]; then
                        echo -n "Allowing sessions again "
                        rm -f /etc/shutmsg
                else
                        echo -n "Was not suspended "
                fi
                echo
                ;;
        *)
                echo -n "Usage: $0 {start|stop|restart|status|reread|resume"
                hash ftpshut
                if [ $? = 1 ]; then
                        echo '}'
                else
                        echo '|suspend}'
                        echo 'suspend accepts additional arguments which are passed to ftpshut(8)'
                fi
                exit 1
esac

if [ $# -gt 1 ]; then
        shift
        $0 $*
fi
exit 0
================+================+=================

# chomd 755 /etc/init.d/proftpd
# chkconfig –-add proftpd
# chkconfig proftpd on

到这里ftp服务器端安装设置完毕,登陆服务器的客户端我用了完全免费的FileZilla(前两天网上看到说FileZilla支持SSL不错)。FileZilla的设置也比较简单。本服务器支持两种客户端加密连接方式:

1. FTP over ssl (显示加密)方式连接。
2. FTP over tls (显示加密) 方式连接

如下图所示:

[ 本帖最后由 llzqq 于 2005-12-3 07:42 编辑 ]


DSC0000.jpg

2. FTP over tls (显示加密)



DSC0001.jpg

2. FTP over ssl (显示加密)

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-71767-1-1.html 上篇帖子: 如何利用肉鸡上的Serv-U Ftp服务器 下篇帖子: ubuntu下安装ftp服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表