LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-27-2018, 12:17 AM   #1
birdy-97
LQ Newbie
 
Registered: Jun 2017
Location: Santa Cruz, California
Distribution: Debian 8.7, OpenIndiana 17.10, Centos 7, Linux Mint
Posts: 18

Rep: Reputation: Disabled
How to stop an attacker over ssh?


Hello everybody, I have an epidemic. Just recently I have found out there has been an attacker trying to get into my self hosted web server.The first instance of this happened on May 10th, of which the attacker tried unsuccessfully to log in as root over ssh. Luckily I had the root account disabled from ssh, and fail2ban banned the attacker's ip address after 4 failed attempts.

The 2nd instance happened today (May 26th) around 6 pm local time. This time trying multiple user names. If one user name and password didn't work , then the attacker would move on to the next common user name.

I know for a fact, that this person is using a vpn/proxy as the person's ip address was different on the 2nd attempt.

I am not too sure how to thwart off an attack like this, nor am I sure what will happen next. So far, the steps I have taken is to turn disable ssh for now, until I can think of another port to put it on.

What actions should/can I take to thwart off this attacker? Will it be safe to wait before I re-forward a brand new ssh port?

Some helpful information: My server is port forwarded through the home router, and only a select few of ports are forwarded to the outside world. Also my web server does not use the default ssh port, instead I was using a custom ssh port number.
 
Old 05-27-2018, 01:07 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,327
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
It's probably not a person or at least not directly. You have remote root access disabled, that is excellent. Also be sure to use keys for all the other accounts and disable password authentication. Then they can't get in without both one of your keys and its passphrase. Lastly continue to do as you are doing with either fail2ban or sshguard.

Here is some reading on what is probably going on:

https://bsdly.blogspot.com/2013/10/t...s-learned.html
https://bsdly.blogspot.com/2012/04/i...n-seconds.html

https://bsdly.blogspot.com/2013/02/t...igh-ports.html

https://bsdly.blogspot.com/2009/04/s...-are-back.html

tldr; if it's visible on the net, bots are going to be jiggling the doorknobs all the time
 
1 members found this post helpful.
Old 05-27-2018, 02:23 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by birdy-97 View Post
I know for a fact, that this person is using a vpn/proxy as the person's ip address was different on the 2nd attempt.
then how can you know that this is the same person?

fwiw, i have the same setup as you down to non-standard port and fail2ban, so i have an interest in this.
can't say i've had similar problems though.
if you don't use ssh keys, now is the time to start using them (well actually you should've used them from the very start).
 
1 members found this post helpful.
Old 05-27-2018, 05:50 AM   #4
laracraft
LQ Newbie
 
Registered: Mar 2018
Location: Bangladesh
Posts: 11

Rep: Reputation: 0
Make sure you pay attention to the warnings about changes to the server's public key. If you get a warning like this, say "no" and check the public key fingerprint through out-of-band means; don't say "yes" unless you have verified the public key fingerprint somehow.
 
Old 05-27-2018, 07:49 AM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Just asking, but what is so special about a break-in attempt? On all publicly available servers I run my auth.log is thousands of lines long with SSH and SMTP attacks. 24/7. Most are scripts, because it is mostly the same pattern which is used. The root user with a variety of passwords, and then a list of user names in alphabetic order.

It seems logical, if you have an open port, access is attempted.

I am not sure if disabling SSH root access is useful. If I can log in, I am sudoer. However, I log in using key authentication, and for the sudo command a cracker needs my password in addition. That is a security step over just root access.

So I have root access disabled, and SSH only through key authentication.

On some servers I run fail2ban, which is IMHO an excellent tool for repeated break-in attempts. But it is a nuisance on mail servers. If there is just one user on the network making a mistake with the password and periodic mail check is enabled, fail2ban simply stops all mail traffic for the network until you have found the culprit.

Changing the SSH port is also a good idea. It does not provide any additional security. But many cracking scripts only try port 22. So you reduce the number of attacks. Not more, not less.

jlinkels
 
Old 05-27-2018, 07:54 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,327
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by jlinkels View Post
But many cracking scripts only try port 22.
[citation needed]

The scripts seem to find me on whichever port I have. I've found that turning of password authentication makes more of a difference and that the scripts mostly give up then. I still get occasional probes but not the 1000s of login attempts like when passwords are turned on.
 
Old 05-27-2018, 08:21 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,904

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
Quote:
Originally Posted by Turbocapitalist View Post
[citation needed]

The scripts seem to find me on whichever port I have. I've found that turning of password authentication makes more of a difference and that the scripts mostly give up then. I still get occasional probes but not the 1000s of login attempts like when passwords are turned on.
probably he meant that is the default port and that's why it is tried first/most.

Was not mentioned (or just I missed) there is a port-knocking feature, see here: https://linux.die.net/man/1/knockd - if you wish.
 
Old 05-27-2018, 08:54 AM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by pan64 View Post
probably he meant that is the default port and that's why it is tried first/most.
Agreed. And I also tried to point out that using a different port is not offering better protection. They find you, but hopefully less often.

jlinkels
 
Old 05-27-2018, 08:56 AM   #9
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
What I also should add is that some people are in favor of closing SSH on the external IP address completely and only use a VPN to connect over SSH. That makes breaking in over SSH impossible as SSH is no longer exposed to the outside world.

jlinkels
 
Old 05-27-2018, 11:50 AM   #10
birdy-97
LQ Newbie
 
Registered: Jun 2017
Location: Santa Cruz, California
Distribution: Debian 8.7, OpenIndiana 17.10, Centos 7, Linux Mint
Posts: 18

Original Poster
Rep: Reputation: Disabled
Thank you, all of you for your advice. I know that it isn't a big deal to begin with, but this was my first time ever seeing something like this occurring on my self hosted web server. So far I have changed the ssh port I was previously using (2220), and I will monitor my ssh/fail2ban logs in case anything else happens. I'll also research how to implement these "Anti-Bruteforce Rules" from this article. As this seems like it will be a good layer to add to my server.

Turbocapitalist thanks for those articles, it seems to be exactly what I was facing with. Sometime later today I will implement ssh keys and disable password authentication. I have also been thinking about two factor authentication through ssh as a possible secondary solution. That vpn idea also sound very interesting, as well as elimination of any known threats.

And you guys are right, I don't know if this is the same person, or simply a script-kiddy/bot. I just assumed it was the same person, but at the end of the day I'll never know.
 
Old 05-28-2018, 12:31 AM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ you haven't mentioned keys.
you really, really need to use ssh keys. forget about 2FA, that's overthinking.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Attacker + Boredom = Fun LazerPhreak General 21 03-21-2010 08:15 PM
How to trace the attacker? arkaan Linux - Security 10 04-11-2007 06:24 AM
attacker on same subnet? LQ? Linux - Security 7 10-18-2005 11:55 PM
finding an attacker loganwva Linux - Security 7 09-03-2003 10:52 PM
How about this attacker? pe2338 Debian 5 09-03-2003 05:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration