Live data from Hacker News

SSHGuard

sshguard.net

81–90 of 149 posts

Re: SSHGuard

#81
post #33

I would probably use something like pam_tally or pam_shield, since it's taking counts directly from the login flow and not via log files. Mentioned in other comments, protecting from brute force isn't really the big benefit. The benefit is reducing noise in logs so that you can see more serious activity.

[deleted]

Re: SSHGuard

#82
post #80

Earlier quoted context omitted.

I _WANT_ to harvest IP's of PC's trying to SSH into any of my servers. I want them because then I can block ALL traffic coming from their IP's. At my last gig, I had thousands of domains and hundreds of servers running on every major (and a shitload of minor) service provider. I custom scripted all these servers to compile all the IP's that attempted a connection, send those lists back to HQ, and then distribute back…

There is a whole Internet worth of random IPv4 addresses being variously used to variously attack various computers. Your blocklist doesn't even approximate it. What's the point of trying to track and block 0.000000001% of the machines that might be used to attack you?

What’s worse, those IPs are probably (at least in part) dynamic, from VPS servers in data centres, or using residential Proxies or compromised machines behind a NAT. A soon as those addresses change or get assigned another customer, you’re blocking potentially legitimate traffic…

Re: SSHGuard

#83

I get keys are better than passwords, but how do you enforce key rotation for non-technical users when they can barely manage to changer their passwords? I much prefer 2FA than keys for non-technical users.

For keys used in authentication, I feel like rotation largely just protects against keys being leaked. If you can enforce keys to exist only on a secure element then to me I feel like rotation is no longer needed in this particular scenario. With the exception of the key strength no longer being enough or something similar.

Perhaps I'm overlooking something?

Re: SSHGuard

#84
PSA: If you are using AWS, you should be using Session Manager for remote access to your EC2 instances if possible - it is free and trivial to enable. Azure offers Azure Bastion, which is exactly what it says. Both of these can keep hostile SSH connections completely away from your servers, and also help to aggregate access logs.

Re: SSHGuard

#85
post #49

Earlier quoted context omitted.

Fail2ban is written in Python and managed to have a vulnerability.

Since when being written in Python automatically makes a program less vulnerability prone than usual?

Well it does make the developer try harder to have a vulnerability. You can't just forget to bound check an array indexing, you need to actually take instructions from the Internet (e.g. eval, import, or exec in case of fail2ban), but of course the way this happens is usually very indirect (e.g. race condition).

No programming language can stop a determined developer from creating a vulnerability, but some languages make the task easier than others.

Re: SSHGuard

#86

One to two lines of iptables limits connection attempts, making a brute force attack take thousands of years. No logging, no monitoring, no extra software. If you only use SSH keys, no brute force attack will work anyway. https://www.systutorials.com/how-to-use-iptables-to-limit-ra... https://making.pusher.com/per-ip-rate-limiting-with-iptables... https://stackoverflow.com/questions/18616246/iptables-limit-... https:…

The iptables methods all have the flaw that multiple sequential short-lived successful connections will trigger a ban too. Limiting Internet-facing SSH connections to key-only is definitely a good idea, though.

I experienced this at a previous company. Yocto/bitbake wanted to do a lot of git clones over SSH very quickly, but a firewall interpreted this as a brute force because it couldn’t tell that each SSH connection was actually successfully authenticating.

Re: SSHGuard

#87
post #76
post #24

If you disable password auth completely (you're using key auth... right???) most of the password bruteforcers will just go away.

I'd expect a (ex?) crypto developer to think security from another perspective, but what if the key is leaked? It's time another prevention system may save your day.

If your private SSH key is leaked, you can expect the attacker to come up in with a single successful login attempt, sshguard, fail2ban etc. won't help.

The only help against that scenario is a true multi factor setup, or maybe a hardware-based security token that needs a second factor (fingerprint or PIN) to unlock.

Re: SSHGuard

#88

Earlier quoted context omitted.

I agree. I never understood why people use all this stuff. If you use strong enough passwords, it's impossible to be brute-forced, simple as that. If you can't control people on your servers and afraid of weak passwords, just disable password authentication and that's about it. Now the issue of logs is real. I tried to configure debian to remove noise from the logs and I couldn't. May be someone with more knowledge w…

> I never understood why people use all this stuff ... Now the issue of logs is real. I tried to configure debian to remove noise from the logs and I couldn't. Sounds like you understand at least one reason people use stuff like this (including, most prominently, fail2ban ). Rate limiting and banning IPs trying to brute force and/or probe open ports (not just SSH) goes a long way to cleaning up your logs, your real t…

> Rate limiting

You don't need fail2ban to rate-limit SSH.

RFTM ... MaxStartups, PerSourceMaxStartups, PerSourceNetBlockSize.

> trying to brute force

     AuthenticationMethods publickey
     PasswordAuthentication no
     ChallengeResponseAuthentication no
     PermitRootLogin no

Re: SSHGuard

#89

Earlier quoted context omitted.

The iptables methods all have the flaw that multiple sequential short-lived successful connections will trigger a ban too. Limiting Internet-facing SSH connections to key-only is definitely a good idea, though.

I experienced this at a previous company. Yocto/bitbake wanted to do a lot of git clones over SSH very quickly, but a firewall interpreted this as a brute force because it couldn’t tell that each SSH connection was actually successfully authenticating.

You can enable SSH connection persistence by adding this to ~/.ssh/config:

    ServerAliveInterval 60
    ControlMaster auto
    ControlPath ~/.ssh/conn/%r@%h:%p
    ControlPersist 1h
I use it to speed up new SSH connections after the first one is made, but it should also prevent the issue you've described.

Re: SSHGuard

#90
post #3

In a sane configuration, the only thing a tool like this should be doing for you is keeping your logs clear. If you're deploying something to mitigate the risk of brute-force attacks on your server, the problem is that it's possible to brute-force your server, not that you don't have an autoblocking system enabled. These tools are popular, but I think they're kind of silly. Later I read some comments below, which com…

  But it's even scarier: it's written in C.
I don't want to defend this tool, but OpenSSH is written in C as well :).
Post reply on HN