|
Ein ssh Server erlaubt den Zugriff auf einen Server vom Internet aus.
D.h. ein jeder kann, in der sshd Standardfallkonfiguration, sofern er
Userid und Passwort kennt oder errät auf den Server zugreifen. Wenn er
dann noch root Rechte erlangt ist der Server schnell unter Kontrolle
des Angreifers und wird dann möglichst verdeckt zu diversen Dingen
missbraucht (ftp-server, DOS Client, Mail SPAM Schleuder, ...) und der
Eigentümer des Servers haftet rechtlich fuer alle Aktionen, die von dem
Server ausgehen. Das kann unangenehm bis teuer werden ... Die folgende Seite bechreibt,wie man seie sshd Server Config aendernmuss, um den Server vor Angriffen zu sichern.
===> English <===
A ssh server is the most common way to access a server which is connected to the internet.
Everybody who knows a userid and password or guesses them can access the server if the standard ssh configuration is used. If he succeeds to get root access the server can be compromized by the attacker and will be used as ftp-server, DOS client, mail SPAM sender ... and the owner of the server is liable for any activities of the attacker. That's awkward and can become quite expensive. The following page describeshow to modify the sshd config file to make the ssh server secure and protectagainst any attacks.
Deshalb muss sich jeder, der einen Server ins Netz stellt genau überlegen wie er den Zugriff auf den Server sichern will.
Folgende Dinge sind ein MUSS:
- root Zugriff per ssh verbieten
- Wenn moeglich nur Zugriff mit keys erlauben. Ansonsten sichere Passwoerter benutzen
- Zugriffsmoeglichkeiten soweit wie moeglich einschraenken
- ssh attacks abwehren
Die sshd_config Parameter sollten folgendermassen sein:
- PermitRootLogin no
- Protocol 2
- AllowGroups users
- AllowUsers xxx yyy zzz, xxx, yyy und zzz sind user die aufs System per ssh dürfen
- ClientAliveInterval 15
- LoginGraceTime 10
- PubkeyAuthentication yes
- PasswordAuthentication no
- MaxAuthTries 3
- MaxStartups 1
- PrintLastLog yes
- KeepAlive no
Folgende Massnahmen koennen ergriffen werden um ssh Attacks zu unterbinden:
- http://denyhosts.sourceforge.net/ installieren. Damit werden alle Ips per iptables geblocked, die ssh attacks versuchen
- Port xx wobei xx ein unbenutzer Port ist in sshd_config. Damit laufen alle ScriptKiddies ins Leere.
-
Eintrag der folgenden Zeilen in die SuSEfirewall2-custom. Damit werden ssh Attacks extrem verzoegert:
iptables -I INPUT -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
iptables
-I INPUT -p tcp --dport 22 -m state --state NEW -m recent --update
--seconds 1200 --hitcount 2 --rttl --name SSH -j LOG --log-prefix
SSH_brute_force
iptables -I INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 1200 --hitcount 2 --rttl --name SSH -j DROP
- Ein VPN einrichten. Dann ist der ssh Port nicht mehr von aussen zu sehen.
- Hosts.allow/.deny sollte benutzt werden können, da tcp_wrappers support normalerweise standmäßig eingebaut ist bei sshd.
Wie kann man prüfen ob tcp_wrappers verfügbar ist?
[framp@obelix ~]$ ldd /usr/sbin/sshd | grep 'libwrap.so'
libwrap.so.0 => /usr/lib/libwrap.so.0 (0x00a7700)
Wenn etwas mit 'libwrap.so' zurückgegeben wird, funktioniert tcp_wrappers mit sshd.
That's why you have to careful think about how you protect your server when you setup a server in the internet.
Following config is mandatory:
- Disable root access with ssh
- Allow access with ssh keys ony. Otherwise make sure secure passwords are used only
- Reduce the access to a minimum
- Deny ssh attacks
Following sshd_config parameters should be used:
- PermitRootLogin no
- Protocol 2
- AllowGroups users
- AllowUsers xxx yyy zzz, xxx, yyy and zzz are user who are allowed to access the system with ssh
- ClientAliveInterval 15
- LoginGraceTime 10
- PubkeyAuthentication yes
- PasswordAuthentication no
- MaxAuthTries 3
- MaxStartups 1
- PrintLastLog yes
- KeepAlive no
Use the following procedures to reject ssh attacks:
- Install http://denyhosts.sourceforge.net/. This blocks all IPs which try ssh attacks
- Us port xx where xx is an unused port. That way all the script kiddies are unsuccessfull.
-
Add following lines in SuSEfirewall2-custom. They delay all ssh attacks and make them useless:
iptables -I INPUT -p tcp --dport 4 -m state --state NEW -m recent --set --name SSH
iptables
-I INPUT -p tcp --dport 4 -m state --state NEW -m recent --update
--seconds 1200 --hitcount 2 --rttl --name SSH -j LOG --log-prefix
SSH_brute_force
iptables -I INPUT -p tcp --dport 4 -m state --state NEW -m recent
--update --seconds 1200 --hitcount 2 --rttl --name SSH -j DROP
- Create a VPN. That way the ssh port is not visible and accessible.
- Use Hosts.allow/.deny
References:
|