News for hackers. Stuff that matters.
Re:Practical Linux Hardening Guide by Havoc on Thursday January 24, 2019 @05:01PM (#18993467)
Also...stick the SSH on a non-default port. Cuts login attempts down to near zero.
Re:Practical Linux Hardening Guide by yjftsjthsd-h on Thursday January 24, 2019 @05:11PM (#18993557)
This is less of a hardening tip and more of a log quieting tip.
Re:Practical Linux Hardening Guide by leeoniya on Thursday January 24, 2019 @05:13PM (#18993572)
it cuts down the drive-by noise by 97%. which lets you not overlook anomalies in the remaining 3%.

we also had a bunch of scanners probing for common php scripts on the http server (we don't run php). simply returning a 404 header and disabling logging in nginx for \.php$ uris cut down a bunch of garbage (mostly from China). additionally, using ngx_http_limit_req_module reduced the effects of numerous DoS-type scanners.

so far, this + iptables for only 80/443/ssh has been a superior solution to instaling fail2ban that continually scans bloated log files and performs constant iptables banning/unbanning foo.

clean logs are essential, not just nice to haves.

Re:Practical Linux Hardening Guide by Someone1234 on Thursday January 24, 2019 @05:17PM (#18993600)
Well said.

"Log noise" is a legitimate security concern all by itself. It is actually disappointing how rarely it is discussed, and how in this world of "AI everywhere" there's no great smart AI log analysers to reduce the signal:noise.

Moving the SSH port might "only" reduce noise, but that's a legitimate security goal in its own right.

Re:Practical Linux Hardening Guide by seanwilson on Friday January 25, 2019 @09:10AM (#18997944)
> "Log noise" is a legitimate security concern all by itself. It is actually disappointing how rarely it is discussed, and how in this world of "AI everywhere" there's no great smart AI log analysers to reduce the signal:noise.

That's because after many people learn about not using "security through obscurity" they apply the rule without thinking as if obscurity never has any benefit for anything.

Re:Practical Linux Hardening Guide by thaumaturgy on Thursday January 24, 2019 @06:36PM (#18994150)
That's because people can't agree on what is or isn't valuable.

For instance, if I (or my software anyway) see a bunch of sshd login attempts from some IP, and then that IP decides to try imap ... yeah, that's getting insta-blocked.

And that's hard to do if you decide to just ignore the sshd attempts.

Re:Practical Linux Hardening Guide by hawski on Friday January 25, 2019 @03:57AM (#18996550)
Could additional honey pot on 22 help? Run sshd on non-standard port and honey pot on 22. Then automatically ban all the hosts that would connect to it. There could be a concern for a mistake, so then ban for limited time at first or something.
Re:Practical Linux Hardening Guide by tempfs on Thursday January 24, 2019 @09:19PM (#18995012)
Nothing externally accessible should allow password login at all.

SSH key-based logins are so much more secure and convenient as heck once you invest the time to learn how they work.

Re:Practical Linux Hardening Guide by systematical on Friday January 25, 2019 @01:27AM (#18995986)
For PCI you still need two factor. Its overkill, but we kept password logins even after having keys.
Re:Practical Linux Hardening Guide by amaccuish on Sunday January 27, 2019 @04:38PM (#19013937)
A smartcard is still fairly convenient and allows you to tick the two-factor box (card + pin)
Re:Practical Linux Hardening Guide by hackbinary on Thursday January 24, 2019 @07:12PM (#18994356)
What about tarpitting known spurious attacks? Possibly proxying/forwarding to a different host?
Re:Practical Linux Hardening Guide by dokument on Thursday January 24, 2019 @05:45PM (#18993824)
Additionally having a non-standard port does help defend against 0day exploits before patches are available or before you are able to disable the port.
Re:Practical Linux Hardening Guide by Wintereise on Thursday January 24, 2019 @07:36PM (#18994460)
The proper solution to this is having a separate management network that already requires authentication for getting into.

However, indeed. Minimized log noise is great for analyzing anomalies manually.

Re:Practical Linux Hardening Guide by tptacek on Thursday January 24, 2019 @05:48PM (#18993842)
When was the last preauth remote vulnerability in OpenSSH?
Re:Practical Linux Hardening Guide by leeoniya on Thursday January 24, 2019 @05:53PM (#18993882)
nevertheless, past performance is not an indicator of future outcomes, right?
Re:Practical Linux Hardening Guide by tptacek on Thursday January 24, 2019 @06:10PM (#18994000)
Past performance doesn't guarantee future performance. It's usually a very strong indicator.

Putting SSH on a nonstandard port is pretty silly.

Re:Practical Linux Hardening Guide by leeoniya on Thursday January 24, 2019 @06:25PM (#18994085)
> Putting SSH on a nonstandard port is pretty silly.

what's the alternative while still keeping ssh logs that aren't filled with thousands of login attempts from bots per day? afaik there isnt any solution that is both as simple and as effective as changing the port.

Re:Practical Linux Hardening Guide by viraptor on Thursday January 24, 2019 @08:19PM (#18994687)
Access behind VPN connection. Or deal with the logs in a better way. If SSH noise bothers you, you can either direct it to a different file, or setup a log aggregator where it's trivial to see what you want (or filter out what you don't by default)
Re:Practical Linux Hardening Guide by deathanatos on Thursday January 24, 2019 @07:07PM (#18994326)
fail2ban will cut down on log noise signficantly, while still allowing you to operate on the standard port. It also thwarts brute-force login attempts, if you're using password authentication. (Which you shouldn't, without good reason. Use public key authentication.)
Re:Practical Linux Hardening Guide by tyingq on Thursday January 24, 2019 @07:34PM (#18994450)
I like pam_shield a bit better than fail2ban. It's directly tied to pam, versus trolling logs, so the configuration and operation is cleaner.
Re:Practical Linux Hardening Guide by philg_jr on Friday January 25, 2019 @10:00AM (#18998455)
https://github.com/jtniehof/pam_shield

Last commit June 2012? Does it work with modern distros?

Re:Practical Linux Hardening Guide by tyingq on Friday January 25, 2019 @10:10AM (#18998567)
Yes. Using it now with Ubuntu 18.04. Available via apt-get.
Re:Practical Linux Hardening Guide by ryanlol on Saturday January 26, 2019 @08:45AM (#19006250)
Not sure if it’s sad or hilarious that people recommend fail2ban as a solution to log spam (or as a solution to anything really)

Do you really think making firewalling decisions based on unstructured attacker-controlled log data is a good idea?

Re:Practical Linux Hardening Guide by romeisendcoming on Monday January 28, 2019 @01:34PM (#19019824)
You control what fail2ban does with said log data and what actually gets logged. There are better ways than fail2ban of course but it's not the worst solution on the planet.
Re:Practical Linux Hardening Guide by ryanlol on Wednesday January 30, 2019 @10:36AM (#19035868)
If you're using regex to parse attacker controlled files I'm not entirely sure if you're in control.

Many unexpected things can happen, as a simple example SSH can generate log entries like this

  Jan 30 17:37:04 server sshd[26695]: Invalid user root from 127.0.0.1 from 10.0.0.1
The default rules can deal with this specific example, but this is certainly a path I wouldn't want to go down myself.
Re:Practical Linux Hardening Guide by zdkl on Thursday January 24, 2019 @06:48PM (#18994215)
Could you please expand on your point ? I understand that security by obscurity is not optimal, but I don't see a good reason not to switch ports.
Re:Practical Linux Hardening Guide by leeoniya on Thursday January 24, 2019 @06:53PM (#18994258)
i think the main argument for leaving it default is [1] for any additional/new sysadmin that has to touch the system. but imo this goes both ways; i'd rather not have my house key hidden under my doormat, where every burglar can check for it in a few seconds. if i taped the key to a random tree branch (even in plain sight), it would be a much safer bet.

[1] https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...

Re:Practical Linux Hardening Guide by throwawaymath on Thursday January 24, 2019 @07:33PM (#18994443)
If you're going to insist on a security analogy involving keys and doors in the real world, a better one would be that the attacker has to search every single atom of the doormat to find the key. If you have PubKeyAuthentication enabled and PasswordAuthentication disabled, the world will end before the attacker finds your key (in expectation).

Changing SSH to a non-standard port is an inelegant solution and doesn't actually bolster security.

Re:Practical Linux Hardening Guide by killaken2000 on Thursday January 24, 2019 @11:52PM (#18995660)
Does it _harm_ security?
Re:Practical Linux Hardening Guide by xorcist on Friday January 25, 2019 @07:33AM (#18997382)
Perahaps not directly, but it does add to cognitive overhead and makes securing the system as a whole more difficult.

If your environment contains multiple ssh servers running on non-standard ports you would not notice when something out of the ordinary happens.

Something listening to an unexpected port should be something you must look into, not shrug at.

Re:Practical Linux Hardening Guide by romeisendcoming on Monday January 28, 2019 @01:37PM (#19019851)
So standardize on a non-standard port, document it and when you do have ssh probes assume it's targeted rather than just another l33t child running du-jour crack(x).

Moving to non-standard means more sophisticated discovery and possibly a more sophisticated attempt.

Re:Practical Linux Hardening Guide by throwawaymath on Friday January 25, 2019 @12:34AM (#18995825)
No, but it is non-standard. Why do things you don't need to?
Re:Practical Linux Hardening Guide by dx87 on Thursday January 24, 2019 @07:02PM (#18994297)
One reason is because setting it to a random high port allows non-root users to turn on the SSH server if the admin turned it off. Probably not super likely to happen, but it's possible.
Re:Practical Linux Hardening Guide by bch on Thursday January 24, 2019 @07:40PM (#18994482)
It doesn’t need to be on a random high port, just not port 22. 222, for example.
Re:Practical Linux Hardening Guide by romeisendcoming on Monday January 28, 2019 @01:32PM (#19019808)
This is a silly opinion. Of course it's helpful and very useful when used in conjunction with other hardening measures.
Re:Practical Linux Hardening Guide by ynezz on Thursday January 24, 2019 @05:53PM (#18993885)
That's really terrible recommendation. You should add firewall rules and allow SSH access only from trusted hosts, ideally over VPN. It's not about login attempts but about possible bug in SSH (and other network services), because it's all just software, written in C, so believe it or not, but it's there, it's not if but when.
Re:Practical Linux Hardening Guide by wahern on Friday January 25, 2019 @12:56AM (#18995885)
The firewall isn't immune to exploitable bugs: https://nvd.nist.gov/vuln/detail/CVE-2017-18017

Likewise for VPN stacks: https://nvd.nist.gov/vuln/detail/CVE-2017-7521

If you're not prepared to expose a service to the world, you probably should run it at all. Ad hoc, non-standard configurations add substantial complexity and maintenance burdens. Complexity is the enemy of security, and having less time to manage more complex configurations is not a good recipe.

If you really need a service, then choose the best one and move on. The rule of thumb is that if you can reach a service, you should assume anybody else can, as well. This is especially true regarding SSH. I've seen plenty of servers p0wned via SSH, but never by breaking SSH. Instead the vector was always through an SSH user's computer infected by malware.

You want secure SSH? Disable password authentication and force everybody to use smartcard authentication like a Yubikey. I do rate limit SSH access using OpenBSD PF, but only because the authentication failures fill up and pollute the logs.

Re:Practical Linux Hardening Guide by vinay_ys on Friday January 25, 2019 @02:38AM (#18996233)
Have you seen yubikey/smartcard being used for sshin a large team? Would love to hear about your setup and learnings.
Re:Practical Linux Hardening Guide by xorcist on Friday January 25, 2019 @07:42AM (#18997423)
OpenSSH is solid piece of software. It hasn't had any (public) authentication bypasses that wasn't configuration related since it started to look like it looks today. Multiple skilled teams have looked at it thoroughly since. It has also been hardened with things like privsep and sandboxing.

This is not OpenSSL. Language alone does not make a product insecure. For practical purposes it is certainly not just a matter of when.

Contrast that with your VPN product, which probably falls over if someone looks at it funnily. Unless your product is called Wireguard, and we are ten years in the future, perhaps.

Re:Practical Linux Hardening Guide by leeoniya on Thursday January 24, 2019 @05:55PM (#18993897)
> That's really terrible recommendation

it would be if it was meant to be comprehensive.

Re:Practical Linux Hardening Guide by jesterson on Thursday January 24, 2019 @08:50PM (#18994855)
Absolutely this. Sad to see how many people refer changing ssh port to non-standard as "security" measure.
Re:Practical Linux Hardening Guide by icedchai on Thursday January 24, 2019 @05:56PM (#18993901)
Every little bit helps. I have hosts I access from "where ever."
Re:Practical Linux Hardening Guide by fencepost on Saturday January 26, 2019 @03:18PM (#19008204)
It's fallen out of favor these days, but if you're running on firewalls that can be configured for port knocking consider doing that. A non-sequential knock pattern that unlocks the remote IP for X amount of time can prevent a ton of grinding attacks.
Re:Practical Linux Hardening Guide by romeisendcoming on Monday January 28, 2019 @01:40PM (#19019884)
Add a TLS auth channel to the portknock with a wait window and OTP and you are really in business with this approach.
Re:Practical Linux Hardening Guide by rorykoehler on Thursday January 24, 2019 @05:45PM (#18993821)
Just use a jump server and put the rest of your servers on the private subnet for port 22 inbound. Expose your jump server to your vpn only and use 2fa on vpn.
Re:Practical Linux Hardening Guide by cwingrav on Thursday January 24, 2019 @08:32PM (#18994754)
This is so simple to set up and completely removes random attacks. If your jump server/bastion host is attacked... take notice.
Re:Practical Linux Hardening Guide by romeisendcoming on Monday January 28, 2019 @01:42PM (#19019910)
Right. But only bring up your jump server when needed from a CSP. The rest of the time unseen and mostly unknown.
Re:Practical Linux Hardening Guide by aaronmdjones on Friday January 25, 2019 @10:35AM (#18998790)
Also cut down on the host keys (e.g. don't have an RSA/DSA/ECDSA host key if all of your clients support Ed25519 hostkeys) and key exchange algorithms (KExAlgorithms in sshd_config); almost all clients support curve25519-sha256 now, so get rid of all the DH fixed ones. Similarly ciphers; OpenSSH and PuTTY support ChaPoly, so you can get rid of aes-ctr, et al.

I'm not saying decrease your supported algorithms to the point where you break things you're using, but you'd be surprised at how much you can get away with not having and never notice it.

At the end of the day this means all those horrible libssh bots and worms can't even begin an SSH session with you, much less attempt any sort of exploitation or bruteforcing. It still generates an entry in your logs (key exchange algorithm mismatch or the like), but decent syslog daemons can filter out such messages by regexps, and redirect them to another debugging log file that you hardly check unless you're having an issue connecting somewhere. Metalog is an example.

Re:Practical Linux Hardening Guide by noir_lord on Thursday January 24, 2019 @05:10PM (#18993550)
I've had ssh on 47999 for a long time :).

It stopped my logs from getting splattered with failed attempts.

Re:Practical Linux Hardening Guide by noja on Thursday January 24, 2019 @05:24PM (#18993653)
Better to have it listening on a port below 1024, otherwise a non-root user could impersonate the ssh daemon.
Re:Practical Linux Hardening Guide by noir_lord on Thursday January 24, 2019 @05:59PM (#18993931)
I agree except if a non-root user I don't know about is binding to any ports from inside then I'm already hosed.
Re:Practical Linux Hardening Guide by noja on Friday January 25, 2019 @05:34PM (#19003257)
A non-root user might not be a person, it might be a compromised php script.
Re:Practical Linux Hardening Guide by noir_lord on Saturday January 26, 2019 @05:32AM (#19005726)
True but if my system has a compromised anything binding to a port then they can talk to it via whatever they want at that point.

I'm of the opinion that if an attacker gets a local account then I'm already hosed given the regularity of local privilege escalation CVE's

Re:Practical Linux Hardening Guide by deathanatos on Thursday January 24, 2019 @07:10PM (#18994341)
This would be detected by SSH, as the host key wouldn't match. (The impersonator wouldn't be able to use the same host key, as they would need the private key, and that requires root privs.)
Re:Practical Linux Hardening Guide by noja on Friday January 25, 2019 @05:35PM (#19003263)
A lot of people who don't care much for checking keys.
Re:Practical Linux Hardening Guide by ASalazarMX on Thursday January 24, 2019 @05:18PM (#18993615)
Conveniency through obscurity.
Re:Practical Linux Hardening Guide by noir_lord on Thursday January 24, 2019 @05:20PM (#18993626)
Yep, which is far better than 'security' through obscurity.
Re:Practical Linux Hardening Guide by phs318u on Thursday January 24, 2019 @05:22PM (#18993646)
I'm so sorry, but my OCD could not let this pass. It's "convenience" not "conveniency". Sorry.

EDITED TO ADD: I wholeheartedly agree with the sentiment though.

Re:Practical Linux Hardening Guide by dylan604 on Friday January 25, 2019 @01:14AM (#18995942)
look up at that thing whizzing over your head; convenience doesn't rhyme with security. ;-)
Re:Practical Linux Hardening Guide by sliken on Thursday January 24, 2019 @05:13PM (#18993569)
Seems kinda painful. Just turn off passwords and let them try all they want. I find rsync particularly painful with a non-standard port.
Re:Practical Linux Hardening Guide by kardos on Thursday January 24, 2019 @05:53PM (#18993877)
Your .ssh/config can handle that for you?
Re:Practical Linux Hardening Guide by sliken on Thursday January 24, 2019 @06:16PM (#18994032)
Sure, you could try to populate .ssh/config on every machine you ever will try to login from.

Or you could use the standard port, turn off passwords, and wait for the sun to burn out before someone brute forces their way in.

Re:Practical Linux Hardening Guide by romeisendcoming on Monday January 28, 2019 @01:45PM (#19019945)
Or someone can simply own your key holding device as you sip your beverage at the local hotspot or home wifi. Simpler to go after the secret privileged client than the server.
Re:Practical Linux Hardening Guide by amdavidson on Friday January 25, 2019 @03:41PM (#19002293)
Do you sync your ssh keys to all the machines you login from?

How do you ssh-copy-id without some allowance for passworded logins? Especially if you're doing it from such distant machines that you can't scp over a .ssh/config file.

Re:Practical Linux Hardening Guide by sliken on Friday January 25, 2019 @04:38PM (#19002757)
So, I just ssh to whatever machine I need to work on, but occasionally need to rsync or scp files to/from that server.

Sure, I could have puppet push a ~/.ssh/config file everywhere, just seems more effort than it's worth. After all if a hacker wants to know if you are running ssh, it's not hard to scan all ports for ssh.

Why inconvenience yourself more than the attacker?

Re:Practical Linux Hardening Guide by Havoc on Thursday January 24, 2019 @06:51PM (#18994237)
>Seems kinda painful

meh. Just means typing in the port in putty. Pick an easy port - 60k. I can live with that.

Re:Practical Linux Hardening Guide by sliken on Thursday January 24, 2019 @07:04PM (#18994314)
Right, but say you have a dozen machines you login from regularly and maybe a few 100 that you login from occasionally. You want to maintain a ~/.ssh/config on all of them?

Seems like a big inconvenience for minimal extra security. Not like scanning for all open ports that have an ssh listening is hard.

Re:Practical Linux Hardening Guide by joppy on Thursday January 24, 2019 @07:25PM (#18994416)
If you’re already typing in the full address for the server every time, since you don’t have an ssh config file, then is it really so much more work to additionally type the port?
Re:Practical Linux Hardening Guide by mcny on Monday January 28, 2019 @05:46AM (#19016455)
Yes because I will forget to type -p 5223 at some point. If you set up a non standard port against my recommendation and I get banned for trying 22, you better be on call 24/7 for free to unban me.
Re:Practical Linux Hardening Guide by yjftsjthsd-h on Thursday January 24, 2019 @09:04PM (#18994930)
If you are coming from 100s of machines, I would really hope you have your home on NFS or something anyways.
Re:Practical Linux Hardening Guide by Teknoman117 on Thursday January 24, 2019 @05:03PM (#18993490)
For my home network the only thing that's exposed out of my router is an OpenVPN server on a non-default port.
Re:Practical Linux Hardening Guide by gerdesj on Thursday January 24, 2019 @09:23PM (#18995032)
I do similar but I personally recommend OpenVPN on 443/tcp rather than 1194/udp. It looks like SSL traffic because that is essentially what it is. Make sure you use your own locally signed CA and certs and enforce CA trust for a successful connection - to avoid any silly MitM tricks.

There is a reasonable argument against using tcp for the tunnel instead of udp due to what can happen to latency when you have a tcp inside tcp stream when one or the other or both are dealing with retransmits (bear in mind that tcp has some guarantees about delivery, whereas udp does not).

In theory you can get an exponential stand off instead of linear due to tcp (say RDP or http) in tcp (openvpn). In practice I find that it does not generally matter these days and I can generally stream BBC iPlayer when abroad with minimal fuss over OpenVPN.

Re:Practical Linux Hardening Guide by amaccuish on Sunday January 27, 2019 @04:43PM (#19013963)
It's actually very easy to detect OpenVPN on port 443 because it isn't really TLS traffic. Much better to use OpenConnect with ocserv, it opportunistically uses DTLS over UDP on 443, and if it can't do that it can use normal TLS. Much harder detect and gives you the performance boost of UDP when possible.
Re:Practical Linux Hardening Guide by Teknoman117 on Friday January 25, 2019 @02:34AM (#18996209)
My ISP blocks many ports which would generally be considered useful to host services on.

https://www.cox.com/residential/support/internet-ports-block...

Re:Practical Linux Hardening Guide by bobbob1921 on Thursday January 24, 2019 @09:28PM (#18995054)
I have the same , but also have an IP ACL on the VPN ports / protocols (only on new connections). When I do need to Connect from random remote ip , I have a port knocking rule that adds ip for 5min to acl

I actually have the port knock action on a blank website w a unusual subdomain. So we need i it I pull up website and can then vpn in temporaryly

Re:Practical Linux Hardening Guide by amelius on Thursday January 24, 2019 @05:35PM (#18993745)
Or simply use sshguard.
Re:Practical Linux Hardening Guide by systematical on Friday January 25, 2019 @01:25AM (#18995979)
The only benefit of this is clean logs. We had auditd running and the bots blew up our SSH logs. Was so ugly that I killed SSH on all but a single entry point server, which is better security anyways. Then I finally just killed logging failed attempts. Since we use two-factor authentication with a key (you have) + password (you know) I was not very worried about this. Prob should just use something like fail2ban though eh?
Re:Practical Linux Hardening Guide by Havoc on Friday January 25, 2019 @02:41PM (#19001674)
>The only benefit of this is clean logs.

Except no. Less attempts translate directly into less risk.

Re:Practical Linux Hardening Guide by detaro on Friday January 25, 2019 @02:44PM (#19001714)
Less attempts of something that has zero chance of succeeding (password login against a system that requires keys) doesn't really translate into less risk.
Re:Practical Linux Hardening Guide by Havoc on Friday January 25, 2019 @04:21PM (#19002588)
>Less attempts of something that has zero chance of succeeding

All attempts have a >zero chance of succeeding. Honestly...struggling to see how this concept is even remotely contentious or how someone could credibly argue against it.

If the number of brute force attempts drops substantially then the chances of success drop too. This is true for a high security setup and a low security setup. In both cases there is going to be a proportionate drop.