8 ms·
Also...stick the SSH on a non-default port. Cuts login attempts down to near zero.
by Havoc 8y ago
Also...stick the SSH on a non-default port. Cuts login attempts down to near zero.
- Teknoman117 8y agoFor my home network the only thing that's exposed out of my router is an OpenVPN server on a non-default port.
- gerdesj 8y agoI 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.
- Teknoman117 8y agoMy ISP blocks many ports which would generally be considered useful to host services on. https://www.cox.com/residential/support/internet-ports-blocked-or-restricted-by-cox.html https://www.cox.com/residential/support/internet-ports-block...
- amaccuish 8y agoIt'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.
- bobbob1921 8y agoI 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
- noir_lord 8y agoI've had ssh on 47999 for a long time :). It stopped my logs from getting splattered with failed attempts.
- ASalazarMX 8y agoConveniency through obscurity.
- noir_lord 8y agoYep, which is far better than 'security' through obscurity.
- phs318u 8y agoI'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.
- dylan604 8y agolook up at that thing whizzing over your head; convenience doesn't rhyme with security. ;-)
- noja 8y agoBetter to have it listening on a port below 1024, otherwise a non-root user could impersonate the ssh daemon.
- yjftsjthsd-h 8y agoThis is less of a hardening tip and more of a log quieting tip.
- leeoniya 8y agoit 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.
- Someone1234 8y agoWell 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.
- thaumaturgy 8y agoThat'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.
- hawski 8y agoCould 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.
- sliken 8y agoSeems kinda painful. Just turn off passwords and let them try all they want. I find rsync particularly painful with a non-standard port.
- kardos 8y agoYour .ssh/config can handle that for you?
- sliken 8y agoSure, 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.
- amdavidson 8y agoDo 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.
- sliken 8y agoSo, 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?
- romeisendcoming 8y agoOr 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.
- Havoc 8y ago
- amelius 8y agoOr simply use sshguard.
- rorykoehler 8y agoJust 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.
- cwingrav 8y agoThis is so simple to set up and completely removes random attacks. If your jump server/bastion host is attacked... take notice.
- romeisendcoming 8y agoRight. But only bring up your jump server when needed from a CSP. The rest of the time unseen and mostly unknown.
- ynezz 8y agoThat'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.
- leeoniya 8y ago> That's really terrible recommendation it would be if it was meant to be comprehensive.
- icedchai 8y agoEvery little bit helps. I have hosts I access from "where ever."
- fencepost 8y agoIt'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.
- romeisendcoming 8y agoAdd a TLS auth channel to the portknock with a wait window and OTP and you are really in business with this approach.
- jesterson 8y agoAbsolutely this. Sad to see how many people refer changing ssh port to non-standard as "security" measure.
- wahern 8y agoThe firewall isn't immune to exploitable bugs: https://nvd.nist.gov/vuln/detail/CVE-2017-18017 https://nvd.nist.gov/vuln/detail/CVE-2017-18017 Likewise for VPN stacks: https://nvd.nist.gov/vuln/detail/CVE-2017-7521 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.
- systematical 8y agoThe 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?
- Havoc 8y ago>The only benefit of this is clean logs. Except no. Less attempts translate directly into less risk.
- detaro 8y agoLess attempts of something that has zero chance of succeeding (password login against a system that requires keys) doesn't really translate into less risk.
- Havoc 8y ago>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.
- aaronmdjones 8y agoAlso 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.