LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   SSH Security (https://www.linuxquestions.org/questions/slackware-14/ssh-security-4175497886/)

pr0xibus 03-12-2014 03:42 AM

SSH Security
 
Morning guys

I keep getting invalid user attempts

Code:

*******:/home/********# grep "invalid user" /var/log/messages
Mar 12 05:58:37 *********** sshd[1502]: input_userauth_request: invalid user jochen [preauth]
Mar 12 05:58:37 ********** sshd[1502]: Failed password for invalid user jochen from 86.101.234.57 port 54805 ssh2
Mar 12 07:52:50 ***** sshd[1669]: input_userauth_request: invalid user creative [preauth]
Mar 12 07:52:50 ***** sshd[1669]: Failed password for invalid user creative from 86.101.234.57 port 42262 ssh2

I have only listed todays ones so far , I have disabled root logins via SSH and changed the port, but still they appear all day every day. Is their anything else I can do too slow this or stop this completely?

This is on a clean install of 14.1

kirukan 03-12-2014 03:51 AM

Drop all the IP's somewhere in your firewall and allow only trusted IP's.

TenTenths 03-12-2014 04:00 AM

If you can't do what kirukan suggests then make use of fail2ban to block repeat "offenders".

Smokey_justme 03-12-2014 04:35 AM

Just like operating systems targeted for to day-to-day end-users (think Windows) have specific software (malware) to take control over them, *nix systems as a whole (still majorly used as a server) are specifically targeted to gain control..

The most common is trying to brake SSH and e-mail realaying by means of automated scripts/programs (bots)... Think about it, no matter what the distribution, almost all servers will make use of SSH so that users can login to it (and there isn't any better or equal way).. Changing the ports helps a bit, but some bots will even try to scan your ports..

Thus, you have to ensure that you applied redundant security measures.. Disallowing root is a great first step because that's the only one user which is almost (yes, there are distributions without the name 'root') sure to exist. The second would be to create a separate group and allow only members of that group to do SSH.. And the third, to use software like 'fail2ban' (link in TenTenths post)... If it helps, in my experience, with this type of measures none of the servers I've managed have been braken into (well, at least not via SSH).. But, to be fair, none we're hosting very important things..

Good luck

TenTenths 03-12-2014 04:39 AM

Quote:

Originally Posted by Smokey_justme (Post 5133087)
Disallowing root is a great first step because that's the only one user which is almost (yes, there are distributions without the name 'root') sure to exist. The second would be to create a separate group and allow only members of that group to do SSH..

The first two items on our company server build document.

tronayne 03-12-2014 07:59 AM

In addition to fail2ban suggested above, there is also DenyHosts (http://denyhosts.sourceforge.net/); I've used it for years and it effectively bans intruders with either an IPTABLES or /etc/hosts.denyu entry (after some number of failed log in attempts, the address is added to one or the other and connections will be refused). DenyHosts runs as a daemon and you don't have to do any maintenance or twiddling with it once installed.

A nice feature of DenyHosts is that you can share miscreant addresses with other DenyHosts users around the world (they're added to your IPTABLES or /etc/hosts.deny files) periodically.

I run DenyHosts so that it writes to /etc/hosts.deny. New attempts to log in as root, wheel, etc. are appended to /etc/hosts.deny and the site will be denied access on any subsequent attempts to connect (as will all addresses in that file).

Probably worth at least a look-see.

Hope this helps some.

tux_dude 03-12-2014 12:14 PM

Had this issue many, many moons ago. I ran fail2ban initially when I only has ssh open. As I opened up my network (apache, sendmail, etc) I didn't feel safe relying only on fail2ban. I since beefed up my firewall and let it do all the work.
1. Only whitelisted address can get to ssh. I only connect from a few known addresses.
2. I have VPN server to allow access to my network. If you are not serving anything out to the public, VPN is the way to go for remote access.

BCarey 03-12-2014 01:56 PM

You can also turn off the password based login altogether and require usage of keys to use ssh. Oh, and here's another vote for denyhosts

Brian

mancha 03-12-2014 02:34 PM

I enjoyed this solution but I might be a little biased.

--mancha


All times are GMT -5. The time now is 01:51 PM.