Tento příspěvek je součástí seriálu Domácí server s Gentoo
- Domácí server s Gentoo: Úvod
- Domácí server s Gentoo: Hardware
- Domácí server s Gentoo: Gentoo a Linux obecně
- Domácí server s Gentoo: SSH
- Domácí server s Gentoo: IRC
- Domácí server s Gentoo: Etherpad-lite
- Domácí server s Gentoo: www server lighttpd
- Domácí server s Gentoo: BitTorrent Sync
- Domácí server s Gentoo: Tiny Tiny RSS
- Domácí server s Gentoo: FTP server
- Domácí server s Gentoo: WordPress na lighttpd
- Domácí server s Gentoo: /tmp v RAM
- Domácí server s Gentoo: Sdílení souborů přes NFS
Velmi užitečné jsou instrukce na Gentoo Wiki. Pokud plánujete mít SSH přístupné zvenčí, vřele doporučuji vynutit pro přihlášení certifikát.
RSAAuthentication yes PubkeyAuthentication yes PasswordAuthentication no ChallengeResponseAuthentication no UsePAM yes AllowUsers yourusername
sshguard
Sshguard nainstalujte, pokud chcete posílit zabezpečení SSH a bránit se proti případným brute-force útokům.
What is sshguard?
Sshguard monitors servers from their logging activity. When logs convey that someone is doing a Bad Thing, sshguard reacts by blocking he/she/it for a bit. Sshguard has a touchy personality: when a naughty tyke insists disturbing your host, it reacts firmer and firmer. — sshguard.net
Yet another ssh brute force attack and how to protect against it with iptables and sshguard – Tento návod mi pomohl nějak se dostat do problematiky, v praxi jsem ovšem postupoval trochu odlišně.
Co se týče použitých iptables, k dispozici je vyčerpávající seriál na root.cz.
# instalovat sshguard a iptables sshguard emerge -av iptables sshguard # nastavit iptables, aby prijimaly pravidla od sshguard # nahradte 22 cislem portu, na kterem vam bezi ssh iptables -N sshguard iptables -A INPUT -p tcp --dport 22 -j sshguard # ulozit zmeny v iptables /etc/init.d/iptables save # spustit-zastavit-spustit pro projeveni zmen /etc/init.d/iptables start; /etc/init.d/iptables stop; /etc/init.d/iptables start # kontrola, zda jsou pravidla pridana iptables -L -v |
Jelikož používám syslog-ng, stačí do /etc/syslog-ng/syslog-ng.conf
přidat následující řádky:
#create a new destination for sshguard destination sshguardproc { program("/usr/sbin/sshguard" template("$DATE $FULLHOST $MESSAGE\n")); }; #creates a filter called f_sshlogs for auth and authpriv system logs filter f_sshlogs { facility(auth, authpriv) and match("sshd"); }; # for sshguard log { source(src); filter(f_sshlogs); destination(sshguardproc); }; |
a sshguard by měl být funkční.
This post is also available in: Czech