LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-04-2018, 10:26 AM   #1
frostfiretulsa
LQ Newbie
 
Registered: Dec 2018
Posts: 7

Rep: Reputation: Disabled
there were ### failed login attempts since your last successful login...


Hi guys,

linux newbie here.

I get that message every time I log in, and I assume someone is attempting to brute force my root password via SSH.

problem is... I have no idea how to block them. Is there an easy way to auto-block IPs that fail say 3 times in a row?

Sorry if this has been asked. I searched, but likely am using the wrong terms.
 
Old 12-04-2018, 10:33 AM   #2
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: Kubuntu, Ubuntu, Debian, Proxmox.
Posts: 553

Rep: Reputation: 115Reputation: 115
fail2ban
 
Old 12-04-2018, 10:34 AM   #3
frostfiretulsa
LQ Newbie
 
Registered: Dec 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cantab View Post
fail2ban
That was the kick I needed. Thank you!
 
Old 12-04-2018, 10:35 AM   #4
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by frostfiretulsa View Post
I get that message every time I log in, and I assume someone is attempting to brute force my root password via SSH.
I would block root login through ssh altogether, by specifying
PermitRootLogin no (or prohibit-password, which will allow public key login)
in the /etc/ssh/sshd_config file (and restart the ssh daemon).
In recent versions prohibit-password is already the default, so while it doesn't prevent remote systems from trying, they never ever will succeed.

Last edited by ehartman; 12-04-2018 at 10:36 AM. Reason: small expansion
 
Old 12-04-2018, 10:38 AM   #5
frostfiretulsa
LQ Newbie
 
Registered: Dec 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
That works perfect. installed quick and easy, configured in a flash and already in the last 60 seconds its banned 2 IPs. Perfect. Thanks again.
 
Old 12-04-2018, 10:38 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,659

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by frostfiretulsa View Post
Hi guys,
linux newbie here.

I get that message every time I log in, and I assume someone is attempting to brute force my root password via SSH. problem is... I have no idea how to block them. Is there an easy way to auto-block IPs that fail say 3 times in a row? Sorry if this has been asked. I searched, but likely am using the wrong terms.
Yes, but you provide us with no details; things like version/distro of Linux, what (if any) security is between you and this server/Internet, is this home/office, etc. Best advice would be to edit your /etc/ssh/sshd_config file, and set PermitRootLogin to No, and **NEVER, EVER LOG IN OVER THE NETWORK AS ROOT, PERIOD** That is one of the biggest security errors you can make, and there just isn't a need to do it. Log in as your 'regular' user, and su/sudo **ONLY AS NEEDED**

Running as root allows you to make catastrophic mistakes very easily. And instead of blocking port 22 based on failed login attempts, employ better security methods. Don't run SSH on port 22, and only allow SSH access from a list of addresses using the AllowUsers directive in the /etc/ssh/sshd_config file. Something like
Code:
AllowUsers user@10.11.12.13
..will let you log in from that address ONLY. Read the sshd_config documentation. But Linux security is like any other system...it's a process. Lots of steps and each vary depending on need and environment.

Personally, I'd set up openVPN, and sidestep the whole issue.
 
Old 12-04-2018, 10:39 AM   #7
frostfiretulsa
LQ Newbie
 
Registered: Dec 2018
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ehartman View Post
I would block root login through ssh altogether, by specifying
PermitRootLogin no (or prohibit-password, which will allow public key login)
in the /etc/ssh/sshd_config file (and restart the ssh daemon).
In recent versions prohibit-password is already the default, so while it doesn't prevent remote systems from trying, they never ever will succeed.
Good advice. I will do that as soon as I am finished configuring things. Thanks.
 
Old 12-04-2018, 10:55 AM   #8
RickDeckard
Member
 
Registered: Jan 2014
Location: Canton, Georgia, USA
Distribution: Debian 12
Posts: 205

Rep: Reputation: Disabled
Not running SSH on port 22 is more of a "security through obscurity" tactic. I would instead recommend using proper firewall rules to only permit traffic from your client IP address in conjunction with AllowUsers. All other suggestions look great, especially the VPN.
 
Old 12-04-2018, 11:03 AM   #9
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Not running ssh on port 22 IS a good idea, IMO. It should be done in addition to the other recommendations.
 
2 members found this post helpful.
Old 12-04-2018, 11:56 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,659

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by RickDeckard View Post
Not running SSH on port 22 is more of a "security through obscurity" tactic. I would instead recommend using proper firewall rules to only permit traffic from your client IP address in conjunction with AllowUsers. All other suggestions look great, especially the VPN.
While it may touch on "security through obscurity", it is not, but as scasey pointed out just part of a larger solution. Running well-know, and potentially exploitable services on their default ports gives anyone who looks 'low hanging fruit'. They KNOW what that service is, and identifying it is step one in compromising it. Running it on some other port makes it less likely to be picked up by an automatic port scan.

Moving the port is the first part, followed by firewall/login security/whatever.
 
3 members found this post helpful.
  


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
LXer: How To Track Successful And Failed Login Attempts In Linux LXer Syndicated Linux News 0 05-31-2017 09:21 PM
how to disable "last login log" & disable "last login message" when start login. hocheetiong Linux - Newbie 4 02-08-2011 05:35 AM
got a Fedora 9 indication that yum updates were available, but there were no updates landonmkelsey Linux - Software 12 02-08-2009 09:53 AM
What windows VMware 4 network settings were successful for forwarding your connection Armoredcav4 Linux - Software 3 11-02-2003 12:36 PM

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

All times are GMT -5. The time now is 02:35 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