李和博 發表於 2024-1-13 00:00:00

ubuntu服务器安装proftpd ftp服务器步骤

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        一、安装</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode25" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        sudo apt-get install proftpd
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        安装过程中会让选择运行模式:Standalone和Inetd,前者是单一服务器模式,后者是超级服务器模式,<br>
        我选的Standalone。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        二、配置</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode26" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        sudo vim /etc/shells</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        加入如下代码<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode27" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        /bin/false</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        新建用户ftpuser1和用户组ftp并设置密码,此用户不需要有效的shell(更安全),所以选择/bin/false<br>
        给fptuser1<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode28" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        sudo groupadd ftp<br>
        sudo useradd ftpuser1 -p pass -g ftp -d /home/ftp -s /bin/false</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        在/home/ftp目录下新建upload和download目录并修改权限<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode29" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        cd /home/ftp<br>
        sudo mkdir download<br>
        sudo mkdir upload<br>
        cd /home<br>
        sudo chmod 755 ftp<br>
        cd /home/ftp<br>
        sudo chmod 755 download<br>
        sudo chmod 777 upload</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        三、修改proftpd核心配置文件proftpd.conf</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode30" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        sudo vim /etc/proftpd/proftpd.conf<br>
        #<br>
        # /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.<br>
        # To really apply changes reload proftpd after modifications.<br>
        #<br>
        # Includes DSO modules<br>
        Include /etc/proftpd/modules.conf<br>
        # Set off to disable IPv6 support which is annoying on IPv4 only boxes.<br>
        UseIPv6 off # 我们不需要IPv6,所以off<br>
        ServerName "xiaoyigeng's FTP Server" # 修改服务器名<br>
        ServerType standalone # 服务器运行模式,这里填standalone,也可以选<br>
        inetd<br>
        DeferWelcome on # 用户登陆时是否显示欢迎信息<br>
        MultilineRFC2228 on<br>
        DefaultServer on<br>
        ShowSymlinks on<br>
        TimeoutNoTransfer 600<br>
        TimeoutStalled 600 # 可以降到100<br>
        TimeoutIdle 1200 # 发呆超时<br>
        DisplayLogin welcome.msg # 如果上边DeferWelcom设置成on,则显示<br>
        welcome.msg中的内容<br>
        DisplayFirstChdir .message # 更改目录时显示的内容<br>
        ListOptions "-l"<br>
        DenyFilter \*.*/<br>
        # Use this to jail all users in their homes <br>
        DefaultRoot /home/ftp # ftp用户被限制在这个目录中<br>
        # Users require a valid shell listed in /etc/shells to login.<br>
        # Use this directive to release that constrain.<br>
        # RequireValidShell off # 匿名用户要选on<br>
        # Port 21 is the standard FTP port.<br>
        Port 21 # 服务运行的端口<br>
        # In some cases you have to specify passive ports range to by-pass<br>
        # firewall limitations. Ephemeral ports can be used for that, but<br>
        # feel free to use a more narrow range.<br>
        # PassivePorts 49152 65534 # PASV模式下用到的端口<br>
        # If your host was NATted, this option is useful in order to<br>
        # allow passive tranfers to work. You have to use your public<br>
        # address and opening the passive ports used on your firewall as well.<br>
        # MasqueradeAddress 1.2.3.4<br>
        # To prevent DoS attacks, set the maximum number of child processes<br>
        # to 30. If you need to allow more than 30 concurrent connections<br>
        # at once, simply increase this value. Note that this ONLY works<br>
        # in standalone mode, in inetd mode you should use an inetd server<br>
        # that allows you to limit maximum number of processes per service<br>
        # (such as xinetd)<br>
        MaxInstances 30<br>
        # Set the user and group that the server normally runs at.<br>
        User nobody # 服务器运行在nobody用户下<br>
        Group nobody # 服务器运行在nobody组下<br>
        # Umask 022 is a good standard umask to prevent new files and dirs<br>
        # (second parm) from being group and world writable.<br>
        Umask 022 022 # 默认新建文件的权限<br>
        # Normally, we want files to be overwriteable.<br>
        AllowOverwrite on # 文件可以被覆盖<br>
        # Uncomment this if you are using NIS or LDAP to retrieve passwords:<br>
        # PersistentPasswd off<br>
        # Be warned: use of this directive impacts CPU average load!<br>
        # Uncomment this if you like to see progress and transfer rate with ftpwho<br>
        # in downloads. That is not needed for uploads rates.<br>
        #<br>
        # UseSendFile off<br>
        # Choose a SQL backend among MySQL or PostgreSQL.<br>
        # Both modules are loaded in default configuration, so you have to specify the backend <br>
        # or comment out the unused module in /etc/proftpd/modules.conf.<br>
        # Use 'mysql' or 'postgres' as possible values.<br>
        #<br>
        #&lt;IfModule mod_sql.c&gt;<br>
        # SQLBackend mysql<br>
        #&lt;/IfModule&gt;<br>
        TransferLog /var/log/proftpd/xferlog # 传送文件日志<br>
        SystemLog /var/log/proftpd/proftpd.log # 系统运行日志<br>
        &lt;IfModule mod_tls.c&gt;<br>
        TLSEngine off<br>
        &lt;/IfModule&gt;<br>
        &lt;IfModule mod_quota.c&gt;<br>
        QuotaEngine on<br>
        &lt;/IfModule&gt;<br>
        &lt;IfModule mod_ratio.c&gt;<br>
        Ratios on<br>
        &lt;/IfModule&gt;&lt;/p&gt; &lt;p&gt;# Delay engine reduces impact of the so-called Timing Attack described in<br>
        # &lt;a href="http://security.lss.hr/index.php?page=details&amp;ID=LSS-2004-10-02"&gt;http://security.lss.hr/index.php?page=details&amp;ID=LSS-2004-10-02&lt;/a&gt;<br>
        # It is on by default. <br>
        &lt;IfModule mod_delay.c&gt;<br>
        DelayEngine on<br>
        &lt;/IfModule&gt;<br>
        &lt;IfModule mod_ctrls.c&gt;<br>
        ControlsEngine on<br>
        ControlsMaxClients 2<br>
        ControlsLog /var/log/proftpd/controls.log<br>
        ControlsInterval 5<br>
        ControlsSocket /var/run/proftpd/proftpd.sock<br>
        &lt;/IfModule&gt;<br>
        &lt;IfModule mod_ctrls_admin.c&gt;<br>
        AdminControlsEngine on<br>
        &lt;/IfModule&gt;<br>
        # A basic anonymous configuration, no upload directories.<br>
        # &lt;Anonymous ~ftp&gt;<br>
        # User ftp<br>
        # Group nogroup<br>
        # # We want clients to be able to login with "anonymous" as well as "ftp"<br>
        # UserAlias anonymous ftp<br>
        # # Cosmetic changes, all files belongs to ftp user<br>
        # DirFakeUser on ftp<br>
        # DirFakeGroup on ftp<br>
        # <br>
        # RequireValidShell off<br>
        # <br>
        # # Limit the maximum number of anonymous logins<br>
        # MaxClients 10<br>
        # <br>
        # # We want 'welcome.msg' displayed at login, and '.message' displayed<br>
        # # in each newly chdired directory.<br>
        # DisplayLogin welcome.msg<br>
        # DisplayFirstChdir .message<br>
        # <br>
        # # Limit WRITE everywhere in the anonymous chroot<br>
        # &lt;Directory *&gt;<br>
        # &lt;Limit WRITE&gt;<br>
        # DenyAll<br>
        # &lt;/Limit&gt;<br>
        # &lt;/Directory&gt;<br>
        # <br>
        # # Uncomment this if you're brave.<br>
        # # &lt;Directory incoming&gt;<br>
        # # # Umask 022 is a good standard umask to prevent new files and dirs<br>
        # # # (second parm) from being group and world writable.<br>
        # # Umask 022 022<br>
        # # &lt;Limit READ WRITE&gt;<br>
        # # DenyAll<br>
        # # &lt;/Limit&gt;<br>
        # # &lt;Limit STOR&gt;<br>
        # # AllowAll<br>
        # # &lt;/Limit&gt;<br>
        # # &lt;/Directory&gt;<br>
        # <br>
        # &lt;/Anonymous&gt;<br>
        # Valid Logins # 以下部分为设置用户权限部分<br>
        &lt;Limit LOGIN&gt;<br>
        AllowUser ftpuser1<br>
        DenyAll<br>
        &lt;/Limit&gt;<br>
        &lt;Directory /home/ftp&gt;<br>
        Umask 022 022<br>
        AllowOverwrite off<br>
        &lt;Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD&gt;<br>
        DenyAll<br>
        &lt;/Limit&gt;<br>
        &lt;/Directory&gt;<br>
        &lt;Directory /home/ftp/download/&gt;<br>
        Umask 022 022<br>
        AllowOverwrite off<br>
        &lt;Limit MKD STOR DELE XMKD RNEF RNTO RMD XRMD&gt;<br>
        DenyAll<br>
        &lt;/Limit&gt;<br>
        &lt;/Directory&gt;<br>
        &lt;Directory /home/ftp/upload/&gt;<br>
        Umask 022 022<br>
        AllowOverwrite on<br>
        &lt;Limit READ RMD DELE&gt;<br>
        DenyAll<br>
        &lt;/Limit&gt;<br>
        &lt;Limit STOR CWD MKD&gt;<br>
        AllowAll<br>
        &lt;/Limit&gt;<br>
        &lt;/Directory&gt;</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        四、启动、停止、重启服务器</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode31" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        sudo /etc/init.d/proftpd start<br>
        sudo /etc/init.d/proftpd stop<br>
        sudo /etc/init.d/proftpd restart</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        五、维护</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        可以到/var/log/proftpd目录查看日志</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        查看ftp服务器负载命令 ftptop<br>
        查看什么认登陆服务器 ftpwho</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        PS:proftpd中Limit的使用介绍</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        我们用到的比较多的可能是Limit的使用,Limit大致有以下动作,基本能覆盖全部的权限了。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        CMD:Change Working Directory 改变目录<br>
        MKD:MaKe Directory 建立目录的权限<br>
        RNFR: ReName FRom 更改目录名的权限<br>
        DELE:DELEte 删除文件的权限<br>
        RMD:ReMove Directory 删除目录的权限<br>
        RETR:RETRieve 从服务端下载到客户端的权限<br>
        STOR:STORe 从客户端上传到服务端的权限<br>
        READ:可读的权限,不包括列目录的权限,相当于RETR,STAT等<br>
        WRITE:写文件或者目录的权限,包括MKD和RMD<br>
        DIRS:是否允许列目录,相当于LIST,NLST等权限,还是比较实用的<br>
        ALL:所有权限<br>
        LOGIN:是否允许登陆的权限<br>
        针对上面这个Limit所应用的对象,又包括以下范围<br>
        AllowUser 针对某个用户允许的Limit<br>
        DenyUser 针对某个用户禁止的Limit<br>
        AllowGroup 针对某个用户组允许的Limit<br>
        DenyGroup 针对某个用户组禁止的Limit<br>
        AllowAll 针对所有用户组允许的Limit<br>
        DenyAll 针对所有用户禁止的Limit</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        关于限制速率的参数为:<br>
        TransferRate STOR|RETR 速度(Kbytes/s) user 使用者</p>
頁: [1]
查看完整版本: ubuntu服务器安装proftpd ftp服务器步骤