You are not logged in.

#1 2010-06-19 12:55:44

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 617
Website

ssh attack

I think someone is trying to break into my system. I was looking through /var/log/auth.log and found a bunch of ssh attempts.

Jun 18 19:24:19 arch sshd[5810]: Failed password for invalid user test from 61.183.248.218 port 55306 ssh2
Jun 18 19:24:21 arch sshd[5812]: Invalid user test from 61.183.248.218
Jun 18 19:24:21 arch sshd[5812]: pam_unix(sshd:auth): check pass; user unknown
Jun 18 19:24:21 arch sshd[5812]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218 
Jun 18 19:24:24 arch sshd[5812]: Failed password for invalid user test from 61.183.248.218 port 56944 ssh2
Jun 18 19:24:26 arch sshd[5814]: Invalid user webmaster from 61.183.248.218
Jun 18 19:24:26 arch sshd[5814]: pam_unix(sshd:auth): check pass; user unknown
Jun 18 19:24:26 arch sshd[5814]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218 
Jun 18 19:24:29 arch sshd[5814]: Failed password for invalid user webmaster from 61.183.248.218 port 58163 ssh2
Jun 18 19:24:31 arch sshd[5816]: Invalid user username from 61.183.248.218
Jun 18 19:24:31 arch sshd[5816]: pam_unix(sshd:auth): check pass; user unknown
Jun 18 19:24:31 arch sshd[5816]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218 
Jun 18 19:24:33 arch sshd[5816]: Failed password for invalid user username from 61.183.248.218 port 59791 ssh2
Jun 18 19:24:36 arch sshd[5818]: Invalid user user from 61.183.248.218
Jun 18 19:24:36 arch sshd[5818]: pam_unix(sshd:auth): check pass; user unknown
Jun 18 19:24:36 arch sshd[5818]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218 
Jun 18 19:24:38 arch sshd[5818]: Failed password for invalid user user from 61.183.248.218 port 33148 ssh2
Jun 18 19:24:40 arch sshd[5820]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218  user=root
Jun 18 19:24:43 arch sshd[5820]: Failed password for root from 61.183.248.218 port 33962 ssh2
Jun 18 19:24:45 arch sshd[5822]: Invalid user admin from 61.183.248.218
Jun 18 19:24:45 arch sshd[5822]: pam_unix(sshd:auth): check pass; user unknown
Jun 18 19:24:45 arch sshd[5822]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218 
Jun 18 19:24:47 arch sshd[5822]: Failed password for invalid user admin from 61.183.248.218 port 35528 ssh2
Jun 18 19:24:49 arch sshd[5824]: Invalid user test from 61.183.248.218
Jun 18 19:24:49 arch sshd[5824]: pam_unix(sshd:auth): check pass; user unknown
Jun 18 19:24:49 arch sshd[5824]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.183.248.218

What can I do about this? This system is my firewall/wireless access point/home server. They will never be able to log in as root with ssh, because i setup ssh to never allow remote root login, and because the root user has been disabled. Its shell is /bin/false. The only way to do anything is with sudo.

Offline

#2 2010-06-19 12:58:38

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,672
Website

Re: ssh attack

block that ip address.

There is a program that blocks ip address after a certian number of failed attempts but I can not remember what it is called...

Offline

#3 2010-06-19 13:42:13

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: ssh attack

Allan wrote:

block that ip address.

There is a program that blocks ip address after a certian number of failed attempts but I can not remember what it is called...

fail2ban.

You can also use a couple of iptables rules to block repeated failed ssh connections:

iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --rttl --seconds 60 --hitcount 8 -j DROP

fail2ban is probably the easiest and more versatile solution.

Last edited by mikesd (2010-06-19 13:42:50)

Offline

#4 2010-06-19 13:44:01

AngryKoala
Member
Registered: 2009-01-22
Posts: 197

Re: ssh attack

If you use keys, wouldn't it just deny the connection?

Offline

#5 2010-06-19 14:15:43

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: ssh attack

Change your ssh port number; Most automated attack scripts don't bother scanning for ssh servers running on non standard ports.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#6 2010-06-19 14:24:07

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: ssh attack

AngryKoala wrote:

If you use keys, wouldn't it just deny the connection?

I only allow key based authentication for publicly accessible servers though I still block brute force attempts. If nothing else it reduces the size of my log files. smile

Offline

#7 2010-06-19 14:34:53

Nepherte
Member
From: Singapore
Registered: 2008-09-09
Posts: 427

Re: ssh attack

mikesd wrote:
Allan wrote:

block that ip address.

There is a program that blocks ip address after a certian number of failed attempts but I can not remember what it is called...

fail2ban.

Denyhosts is another viable solution.

Offline

#8 2010-06-19 15:14:07

jt512
Member
Registered: 2009-02-19
Posts: 262

Re: ssh attack

Other than keeping your log files short, since the SSH daemon is denying them access anyway, is there any point in doing anything else?  I get hundreds to thousands of failed logins daily.

Offline

#9 2010-06-19 15:27:43

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: ssh attack

Stebalien wrote:

Change your ssh port number; Most automated attack scripts don't bother scanning for ssh servers running on non standard ports.

I do this. After changing the port to a random high-numbered one, I haven't had any break-in attempts at all in over a year. (I also accept only keys for login.)

Offline

#10 2010-06-21 09:04:00

crankyadmin
Member
Registered: 2009-09-27
Posts: 117
Website

Re: ssh attack

Here is another vote for fail2ban. I set mine up to only accept keys and ban after one failed login attempt.

With keys you'll never get denied access and without it you'll get access denied.


:: Github :: My AUR :: Coreboot ::

Offline

#11 2010-06-21 09:14:33

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: ssh attack

Use a high numbered port, restrict access to a single user and specific IP ranges using PAM (/etc/security/access.conf). Or use a combination of IP restrictions in /etc/hosts.allow and PAM.

I like PAM.

Offline

Board footer

Powered by FluxBB