Server lahm - FTP, HTTP und Co...

ProFTPd, vsftpd, pure-ftpd
Post Reply
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Server lahm - FTP, HTTP und Co...

Post by TDS »

Ich möchte gern den ProFTP Daemon absichern. Soweit so gut, doch in der Standardkonfiguration wird der Server bei jenden FTP-Download geblockt. Sprich er reagiert erst wieder flüssig wenn der Download/Upload fertig ist. Nach ein paar Recherchen habe ich die Config etwas angepasst. Jedoch kann ich mich jetzt nicht mehr einloggen :?
Hat jemand eine gute Config die alles abdeckt, funktioniert und den Server nicht lahm legt?

Code: Select all

# /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.
# To really apply changes reload proftpd after modifications.
#

# Includes DSO modules
Include /etc/proftpd/modules.conf

# Set off to disable IPv6 support which is annoying on IPv4 only boxes.
UseIPv6                         off
# If set on you can experience a longer connection delay in many cases.
IdentLookups                    off
UseReverseDNS                   off

ServerName                      "ProFTPD"
ServerIdent                     on "--- FTP from TDS ---"
ServerType                      standalone
DeferWelcome                    off
DebugLevel                      3
RootLogin                       off
DefaultTransferMode             binary

MultilineRFC2228 on
DefaultServer                   on

# Timeouts
TimeoutNoTransfer               600
TimeoutStalled                  300
TimeoutIdle                     600

#DisplayLogin                   /home/ftp/welcome.msg
#DisplayChdir                   .message true
ListOptions                     "-l"

# Session
DenyFilter                      *.*/
ListOptions                     "-An +R" strict
UseGlobbing                     off
ShowSymlinks                    on
TimesGMT                        on

TransferRate STOR               128
TransferRate RETR               512

# Log-Formate definieren
SystemLog                       NONE
WtmpLog                         off
LogFormat default               "%h %l %u %t "%r" %s %b"
LogFormat auth                  "%v [%P] %h %t "%r" %s"
LogFormat write                 "%h %l %u %t "%r" %s %b"

AllowRetrieveRestart    on
AllowStoreRestart       on
DeferWelcome            on

# CPU/Mem Limits
RLimitCPU session       10
RLimitMemory session    4096
#RLimitMemory daemon    8192 max

# 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).
MaxClientsPerHost               5
MaxInstances                    30
MaxConnectionRate               4
SocketBindTight                 off

# Use this to jail all users in their homes
# DefaultRoot                   ~

# Users require a valid shell listed in /etc/shells to login.
# Use this directive to release that constrain.
# RequireValidShell             off

# Port 21 is the standard FTP port.
Port                            21

# In some cases you have to specify passive ports range to by-pass
# firewall limitations. Ephemeral ports can be used for that, but
# feel free to use a more narrow range.
# PassivePorts                  60000 61000

# If your host was NATted, this option is useful in order to
# allow passive tranfers to work. You have to use your public
# address and opening the passive ports used on your firewall as well.
# MasqueradeAddress             1.2.3.4

# This is useful for masquerading address with dynamic IPs:
# refresh any configured MasqueradeAddress directives every 8 hours
<IfModule mod_dynmasq.c>
# DynMasqRefresh 28800
</IfModule>

# 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 that the server normally runs at.
User                            dtc     #proftpd
Group                           dtcgrp  #nogroup

# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask                           022  022
# Normally, we want files to be overwriteable.
AllowOverwrite                  on

# Uncomment this if you are using NIS or LDAP via NSS to retrieve passwords:
# PersistentPasswd              off

# This is required to use both PAM-based authentication and local passwords
# #####AuthOrder                        mod_auth_pam.c* mod_auth_unix.c

# Be warned: use of this directive impacts CPU average load!
# Uncomment this if you like to see progress and transfer rate with ftpwho
# in downloads. That is not needed for uploads rates.
#
# UseSendFile                   off

TransferLog /var/log/proftpd/xferlog
SystemLog   /var/log/proftpd/proftpd.log

<IfModule mod_quotatab.c>
QuotaEngine off
</IfModule>

<IfModule mod_ratio.c>
Ratios off
</IfModule>


# Delay engine reduces impact of the so-called Timing Attack described in
# http://security.lss.hr/index.php?page=details&ID=LSS-2004-10-02
# It is on by default.
<IfModule mod_delay.c>
DelayEngine on
</IfModule>

<IfModule mod_ctrls.c>
ControlsEngine        off
ControlsMaxClients    2
ControlsLog           /var/log/proftpd/controls.log
ControlsInterval      5
ControlsSocket        /var/run/proftpd/proftpd.sock
</IfModule>

<IfModule mod_ctrls_admin.c>
AdminControlsEngine off
</IfModule>

#
# Alternative authentication frameworks
#
#Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf

#
# This is used for FTPS connections
#
#Include /etc/proftpd/tls.conf

# A basic anonymous configuration, no upload directories.

# <Anonymous ~ftp>
#   User                                ftp
#   Group                               nogroup
#   # We want clients to be able to login with "anonymous" as well as "ftp"
#   UserAlias                   anonymous ftp
#   # Cosmetic changes, all files belongs to ftp user
#   DirFakeUser on ftp
#   DirFakeGroup on ftp
#
#   RequireValidShell           off
#
#   # 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
#   <Directory *>
#     <Limit WRITE>
#       DenyAll
#     </Limit>
#   </Directory>
#
#   # Uncomment this if you're brave.
#   # <Directory incoming>
#   #   # Umask 022 is a good standard umask to prevent new files and dirs
#   #   # (second parm) from being group and world writable.
#   #   Umask                           022  022
#   #            <Limit READ WRITE>
#   #            DenyAll
#   #            </Limit>
#   #            <Limit STOR>
#   #            AllowAll
#   #            </Limit>
#   # </Directory>
#
# </Anonymous>
# Configured by DTC v0.10 : Please don't touch this line !
AuthOrder               mod_sql.c #mod_auth_pam.c* mod_auth_unix.c
IdentLookups    off
DefaultRoot     ~
SQLAuthenticate on
SQLConnectInfo  dtc@localhost dtcdaemons fc612beaf02fcd9b
SQLAuthTypes    Plaintext
SQLUserInfo     ftp_access login password uid gid homedir shell
# This is the TLS auth support. Thanks to Erwan Gurcuff (gort) for the tip!
<IfModule mod_tls.c>
        TLSEngine on
        TLSLog /var/log/proftpd-tls.log
        TLSProtocol TLSv1
        TLSRequired off
        TLSRSACertificateFile /var/lib/dtc/etc/ssl/proftpd/new.cert.cert
        TLSRSACertificateKeyFile /var/lib/dtc/etc/ssl/proftpd/new.cert.key
        TLSVerifyClient on
</IfModule>
# // Transfer Log to Proftpd
SQLLog RETR,STOR transfer1
SQLNamedQuery transfer1 INSERT "'%u', '%f', '%b', '%h', '%a', '%m', '%T',now(), 'c', NULL" ftp_logs

# // Count Logins per User
SQLLog                PASS logincount
SQLNamedQuery         logincount UPDATE "count=count+1 WHERE login='%u'" ftp_access

# // Remember the last login time
SQLLog                PASS lastlogin
SQLNamedQuery         lastlogin UPDATE "last_login=now() WHERE login='%u'" ftp_access

# // Count the downloaded bytes
SQLLog RETR           dlbytescount
SQLNamedQuery         dlbytescount UPDATE "dl_bytes=dl_bytes+%b WHERE login='%u'" ftp_access

# // Count the downloaded files
SQLLog RETR           dlcount
SQLNamedQuery         dlcount UPDATE "dl_count=dl_count+1 WHERE login='%u'" ftp_access

# // Count the uploaded bytes
SQLLog STOR           ulbytescount
SQLNamedQuery         ulbytescount UPDATE "ul_bytes=ul_bytes+%b WHERE login='%u'" ftp_access

# // Count the uploaded files
SQLLog STOR           ulcount
SQLNamedQuery         ulcount UPDATE "ul_count=ul_count+1 WHERE login='%u'" ftp_access

# End of DTC configuration v0.10 : please don't touch this line !

PS: Wenn jemand für DTC vsftpd zum Laufen bekommt bin ich gern für eine Lösung ansprechbar. pure-ftpd kann ich nicht gebrauchen da dort nur max. 4GB Dateigröße unterstützt wird (jedenfalls kenn ich keine Option die das ausstellt).

Bye, TDS.
Last edited by TDS on 2009-01-04 18:54, edited 2 times in total.
Roger Wilco
Posts: 5923
Joined: 2004-05-23 12:53
 

Re: ProFTPD legt Server lahm

Post by Roger Wilco »

TDS wrote:Soweit so gut, doch in der Standardkonfiguration wird der Server bei jenden FTP-Download geblockt.
Tritt das auch bei anderen Services und einem anderen ftpd auf? Das klingt eher nach einem Problem der Netzwerkverbindung an sich (z. B. nur 10 MBit/s Half-Duplex statt 100 MBit/s Full-Duplex).
TDS wrote:pure-ftpd kann ich nicht gebrauchen da dort nur max. 4GB Dateigröße unterstützt wird
Wer erzählt denn sowas?
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: ProFTPD legt Server lahm

Post by Joe User »

Gemäss http://www.gplhost.com/software-dtc.html ist Dein DTC hoffnungslos veraltet, bitte updaten...
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Re: ProFTPD legt Server lahm

Post by TDS »

Nicht so voreilig :-) DTC ist aktuell, nur die Configs werden von DTC nicht immer mit richtiger Version versehen, weil hard-coded.
Meine Version ist V0.29.14 R1 - debian
User avatar
rudelgurke
Posts: 409
Joined: 2008-03-12 05:36
 

Re: ProFTPD legt Server lahm

Post by rudelgurke »

TDS wrote:SQLAuthTypes Plaintext
Ist dass so gewollt ? Plain Passwörter in der Datenbank ?

Wenn die Tabelle mit ENCRYPT() erstellt wurde sollte hier wohl "Crypt" stehen. Und klappt der gesamte SQL Zugriff manuell mit dem angebenen User ?

Code: Select all

ExtendedLog /var/log/proftpd/auth.log AUTH auth
SQLLogFle /var/log/proftpd/sql.log
In der proftpd.conf helfen vielleicht bei der Übersicht etwas mehr.
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Re: ProFTPD legt Server lahm

Post by TDS »

Das ist so gewollt da es mit DTC ist, und da gibt es leider so etwas nicht :-(
Und das einloggen und Co. klappt auch ganz gut. Nur wenn es um Transfers geht sieht es mau aus.
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Re: ProFTPD legt Server lahm

Post by TDS »

So, ich rudere mal zurück. Nach ergiebigen Tests hat sich herausgestellt das jeder Download, egal welches Protokoll, den Server lahm legt bis er vollständig ist.
Roger Wilco
Posts: 5923
Joined: 2004-05-23 12:53
 

Re: ProFTPD legt Server lahm

Post by Roger Wilco »

Dann schau dir in der Ausgabe von `dmesg` (falls noch vorhanden) oder mit `mii-tool` oder `ethtool` an, welchen Modus deine Netzwerkkarte aktuell fährt. Auch könnte die Fehlerangabe in der Ausgabe von `ifconfig` einen Hinweis geben.
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Re: ProFTPD legt Server lahm

Post by TDS »

Danke für den Tipp: ethtool gab folgendes aus:

Code: Select all

Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 10Mb/s
        Duplex: Half
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: d
        Current message level: 0x00000001 (1)
        Link detected: yes
Und da Switch und Karte das auf Layer 7 aushandeln gibt es dort Probleme. Half Duplex kann nur senden oder empfangen. Demzufogle blockt der Server. Und 10MBit machen ihr übriges...

Wie kann ich das manuell überschreiben in /etc/network/interfaces?
freddy36
Posts: 273
Joined: 2008-03-20 17:31
 

Re: ProFTPD legt Server lahm

Post by freddy36 »

man mii-tool
in der interfaces config gibt es glaube ich keine eigene Option dafür, aber einfach pre-up sollte das ganze Problemlos gehen.
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Re: ProFTPD legt Server lahm

Post by TDS »

So, also das Interface hat sich nicht automatisch eingestellt da es keine valide Config vom Switch erhalten hat. Jetzt ist es manuell eingerichtet via ethtool. Jedoch meint der Hoster es könne Probleme geben falls ich mal über 1TB komme und auf 10Mbit gedrosselt wird.
User avatar
TDS
Posts: 71
Joined: 2004-03-25 07:53
Location: Hannover
Contact:
 

Re: Server lahm - FTP, HTTP und Co...

Post by TDS »

Kann mir jemand nochmals helfen, bzw. sagen was ich ändern muss?
Netzwerk geht soweit, Download auch, jedoch wenn ich Debian Updates downloade (aptitude bzw. apt-get) lahmt der server und ich lade mit max. 10kb/sec.
Apache2:

Code: Select all

<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          100
    MinSpareThreads      20
    MaxSpareThreads      50
    ThreadsPerChild      20
    MaxRequestsPerChild   0
</IfModule>
Aber daran kann es denke ich nicht liegen, oder?
Evtl. an auto-negotiation (aber das war der Grund für die Problem davor).

Code: Select all

Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: No
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: pumbg
        Wake-on: d
        Current message level: 0x00000001 (1)
        Link detected: yes
Früher war ein Update ca. 5min mit ~50MB (update, upgrade), jetzt dauert's ca. 60min... Und an den Debian-Servern sollte es ja nicht liegen.
Kann mir jemand nen Tipp geben?
Post Reply