• This forum has a zero tolerance policy regarding spam. If you register here to publish advertising, your user account will be deleted without further questions.

denyhosts - geht oder geht nicht?

franc

Member
Hallo

ich bin etwas unschlüssig, ob mein denyhosts (die Pre-Release 3.0 vom 27.Juni 2015 auf einem Ubuntu 14.04) überhaupt funktioniert.
Ich habe Logauswertungen von Logwatch (kriege ich täglich per Mail), da steht:

Code:
SSHD
...
Illegal users from:
...
94.76.241.47 (mail.linuxhack.ru): 44 times
     mc: 2 times
     teamspeak: 2 times
     teamspeak3: 2 times
     ts3: 2 times
     apache: 1 time
     backuppc: 1 time
     csserver: 1 time
     default: 1 time
     demo1: 1 time
     deploy: 1 time
     dev: 1 time
     developer: 1 time
     git: 1 time
     git1: 1 time
     gpadmin: 1 time
     home: 1 time
     info: 1 time
     informix: 1 time
     marco: 1 time
     master: 1 time
     media: 1 time
     minecraft: 1 time
     nginx: 1 time
     op: 1 time
     openvpn: 1 time
     oracle: 1 time
     php: 1 time
     prueba: 1 time
     public: 1 time
     shoutcast: 1 time
     spencer: 1 time
     steam: 1 time
     sunrise: 1 time
     support: 1 time
     temp: 1 time
     tsserver: 1 time
     user1: 1 time
     vpn: 1 time
     wordpress: 1 time
     zabbix: 1 time
...

Und in meiner /etc/hosts.deny lese ich auch:

Code:
...
# DenyHosts: Fri Dec  9 05:00:59 2016 | sshd: 221.194.44.229
sshd: 221.194.44.229
# DenyHosts: Sat Jan 21 15:28:46 2017 | sshd: 124.133.7.42
sshd: 124.133.7.42
# DenyHosts: Sat Jan 21 15:28:46 2017 | sshd: 113.240.250.156
sshd: 113.240.250.156
# DenyHosts: Sat Jan 21 15:28:46 2017 | sshd: 43.227.253.93
sshd: 43.227.253.93
# DenyHosts: Sat Jan 21 15:28:46 2017 | sshd: 43.227.253.45
sshd: 43.227.253.45
# DenyHosts: Sat Jan 21 15:28:46 2017 | sshd: 94.76.241.47
sshd: 94.76.241.47
Am Schluss also ebenjene IP!
Warum erlaubt denyhosts da überhaupt 44 Zugriffe?
Kann ich da noch was an den Einstellungen drehen?
Oder sollte ich es einfach in Logwatch einstellen, dass das nicht angezeigt wird?
Kann mir jemand das ganz kurz erklären?

Danke.

Ich hatte das übrigens schon mal in einem fail2ban Thread angeschnitten.

Gruß franc
 
Interessant ist die zeitliche Abfolge der Anmeldeversuche. 44 Versuche an einem Tag können auch so verteilt erfolgen, dass etwa jede halbe Stunde ein Versuch erfolgt.

--
.A.
 
Hm.
Meine Einstellung dazu (?) steht auf 1 Stunde:

Code:
DAEMON_PURGE = 1h

Habe es jetzt aber mal auf 12 Stunden gesetzt.
Das Logfile, wo das von Logwatch ausgelesen wird:

Code:
/var/log/auth.log

(bzw. mittlerweile /var/log/auth.log.1) zeigt die Uhrzeiten der Zugriffe, nämlich immer 11 Minuten liegen dazwischen:

Code:
Jan 19 15:18:07 ew6 sshd[32306]: Invalid user ircd from 94.76.241.47
Jan 19 15:18:07 ew6 sshd[32306]: input_userauth_request: invalid user ircd [preauth]
Jan 19 15:18:07 ew6 sshd[32306]: Connection closed by 94.76.241.47 [preauth]
...
Jan 19 15:29:10 ew6 sshd[32447]: Invalid user http from 94.76.241.47
Jan 19 15:29:10 ew6 sshd[32447]: input_userauth_request: invalid user http [preauth]
Jan 19 15:29:10 ew6 sshd[32447]: Connection closed by 94.76.241.47 [preauth]
...
Jan 19 15:40:13 ew6 sshd[32647]: Invalid user git from 94.76.241.47
Jan 19 15:40:13 ew6 sshd[32647]: input_userauth_request: invalid user git [preauth]
Jan 19 15:40:13 ew6 sshd[32647]: Connection closed by 94.76.241.47 [preauth]
...
Jan 19 15:51:14 ew6 sshd[314]: Invalid user admin from 94.76.241.47
Jan 19 15:51:14 ew6 sshd[314]: input_userauth_request: invalid user admin [preauth]
Jan 19 15:51:14 ew6 sshd[314]: Connection closed by 94.76.241.47 [preauth]
...
Jan 19 16:02:18 ew6 sshd[503]: Invalid user test from 94.76.241.47
Jan 19 16:02:18 ew6 sshd[503]: input_userauth_request: invalid user test [preauth]
Jan 19 16:02:18 ew6 sshd[503]: Connection closed by 94.76.241.47 [preauth]
...
Jan 19 16:13:23 ew6 sshd[673]: Invalid user nagios from 94.76.241.47
Jan 19 16:13:23 ew6 sshd[673]: input_userauth_request: invalid user nagios [preauth]
Jan 19 16:13:23 ew6 sshd[673]: Connection closed by 94.76.241.47 [preauth]
...
Jan 19 16:24:26 ew6 sshd[823]: Invalid user ubnt from 94.76.241.47
Jan 19 16:24:26 ew6 sshd[823]: input_userauth_request: invalid user ubnt [preauth]
Jan 19 16:24:26 ew6 sshd[823]: Connection closed by 94.76.241.47 [preauth]
...

Warum macht denyhosts denn da also nicht dicht?
 
Wird jeder Fehlversuch nach einer Stunde gelöscht, darf bei 5 erlaubten Fehlversuchen alle 11 bis 13 Minuten ein weiterer Versuch erfolgen. Das trifft doch recht genau das geloggte Verhalten.

Hast Du nach der Änderung die config neu eingelesen?

--
.A.
 
Code:
/etc/init.d/denyhosts restart
Stimmt, das hatte ich vergessen!
Danke.
Mal sehen, ob das in der Form jetzt noch mal so kommt.
Dann würden diese Einbruchstester absichtlich so lange warten, um nicht ausgesperrt zu werden? Oder werden die Versuche dazwischen einfach nicht geloggt?
 
Last edited by a moderator:
Die Verbindungsversuche dazwischen fängt libwrap ab. Daher wird von SSH kein Login-Versuch erkannt. Über libwrap kannst Du diese Versuche auch loggen.

--
.A.
 
Mist, nein, das wars nicht. Gestern wieder so einen Eintrag im Logwatch:
Code:
[B]SSHD[/B]
[I]Disconnecting after too many authentication failures for user:
[/I]  admin : 1 Time(s)
  root : 4 Time(s)
[I]Illegal users from:[/I]
  undef: 15 times
     VF-IRhg556 [preauth]: 1 time
     admin [preauth]: 1 time
     digicel [preauth]: 1 time
     homebro [preauth]: 1 time
     kodi [preauth]: 1 time
     moth3r [preauth]: 1 time
     mother [preauth]: 1 time
     osmc [preauth]: 1 time
     pi [preauth]: 1 time
     plexuser [preauth]: 1 time
     telecomadmin [preauth]: 1 time
     ubnt [preauth]: 1 time
     user [preauth]: 1 time
     vodafone [preauth]: 1 time
     xbmc [preauth]: 1 time
  45.33.117.14 (li1054-14.members.linode.com): 142 times
     ubnt: 122 times
     admin: 4 times
     moth3r: 3 times
     user: 2 times
     VF-IRhg556: 1 time
     digicel: 1 time
     homebro: 1 time
     kodi: 1 time
     mother: 1 time
     osmc: 1 time
     pi: 1 time
     plexuser: 1 time
     telecomadmin: 1 time
     vodafone: 1 time
     xbmc: 1 time
  103.19.132.10: 7 times
     admin: 3 times
     moth3r: 2 times
     mother: 1 time
     ubnt: 1 time
  200.119.129.155 (ip-gt.200.119.129.155.telefonica-ca.net): 1 time
     admin: 1 time
...

und im auth.log lese ich dann auch z.B.:

Code:
...
Jan 24 18:47:38 ew6 sshd[4276]: Invalid user mother from 103.19.132.10
Jan 24 18:47:38 ew6 sshd[4276]: input_userauth_request: invalid user mother [preauth]
Jan 24 18:47:38 ew6 sshd[4276]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
Jan 24 18:47:39 ew6 sshd[4278]: Invalid user moth3r from 103.19.132.10
Jan 24 18:47:39 ew6 sshd[4278]: input_userauth_request: invalid user moth3r [preauth]
Jan 24 18:47:39 ew6 sshd[4278]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
Jan 24 18:47:41 ew6 sshd[4280]: Invalid user moth3r from 103.19.132.10
Jan 24 18:47:41 ew6 sshd[4280]: input_userauth_request: invalid user moth3r [preauth]
Jan 24 18:47:41 ew6 sshd[4280]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
Jan 24 18:47:42 ew6 sshd[4282]: Invalid user ubnt from 103.19.132.10
Jan 24 18:47:42 ew6 sshd[4282]: input_userauth_request: invalid user ubnt [preauth]
Jan 24 18:47:43 ew6 sshd[4282]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
Jan 24 18:47:44 ew6 sshd[4284]: Invalid user admin from 103.19.132.10
Jan 24 18:47:44 ew6 sshd[4284]: input_userauth_request: invalid user admin [preauth]
Jan 24 18:47:44 ew6 sshd[4284]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
Jan 24 18:47:45 ew6 sshd[4286]: Invalid user admin from 103.19.132.10
Jan 24 18:47:45 ew6 sshd[4286]: input_userauth_request: invalid user admin [preauth]
Jan 24 18:47:45 ew6 sshd[4286]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
Jan 24 18:47:46 ew6 sshd[4288]: Invalid user admin from 103.19.132.10
Jan 24 18:47:46 ew6 sshd[4288]: input_userauth_request: invalid user admin [preauth]
Jan 24 18:47:46 ew6 sshd[4288]: Received disconnect from 103.19.132.10: 11: Bye Bye [preauth]
...
also nach wenigen Sekunden neue Versuche mit der gleichen IP.
Bei den anderen IPs ebenso.

Denyhosts mit meinen Einstellungen scheint also doch nicht zu funktionieren, oder?
Was mache ich bloss falsch???
 
Hier mal meine Konfig (/etc/denyhosts.conf):

Code:
SECURE_LOG = /var/log/auth.log
HOSTS_DENY = /etc/hosts.deny
PURGE_DENY = 3d
BLOCK_SERVICE  = sshd
DENY_THRESHOLD_INVALID = 5
DENY_THRESHOLD_VALID = 10
DENY_THRESHOLD_ROOT = 1
DENY_THRESHOLD_RESTRICTED = 1
WORK_DIR = /var/lib/denyhosts
SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES
HOSTNAME_LOOKUP=YES
LOCK_FILE = /run/denyhosts.pid
ADMIN_EMAIL = me@example.org
SMTP_HOST = localhost
SMTP_PORT = 25
SMTP_USERNAME=me@example.org
SMTP_PASSWORD=mypassword
SMTP_FROM = DenyHosts <me@example.org>
SMTP_SUBJECT = DenyHosts Report
AGE_RESET_VALID=5d
AGE_RESET_ROOT=25d
AGE_RESET_RESTRICTED=25d
AGE_RESET_INVALID=10d
DAEMON_LOG = /var/log/denyhosts
DAEMON_SLEEP = 30s
DAEMON_PURGE = 12h

Ich hab übrigens auch noch nie ein E-Mail von denyhosts gekriegt (die Adresse habe ich hier natürlich geändert). Eigentlich sollte da doch auch mal was kommen.
 
Back
Top