90 points · by Bluestein · 2y ago · 82 comments
For anyone else reading this, generally speaking one shouldn't use passwords for SSH in 2024. Use public key auth instead.
> Why is it so amazing?
OpenSSH isn't invulnerable. It can have zero-day vulnerabilities. But if it isn't even listening on the public internet, that's one less attack vector.
So you should not rely on fail2ban to keep you safe from anything, and you are introducing DoS risks. Very bad tradeoff imho, making it only good as a last resort.
Installing external dependencies, even from someone trusted like Moxie, is counterproductive. The more system you have the more vulnerabilities, less is more.
I've actually been fired over this, we were building a product, and I implemented port knocking in python. Lead said it was unsecure and wanted to install an encrypted port knocking protocol.
EDIT: Just read the readme, Moxie is saying the same thing verbatim lol, we cool
Why exactly where you fired? Because you used python?
OpenBSD's wg documentation is straightforward. It maps onto wireguard-tools' configuration concepts if you need to use Linux.
1. https://man.openbsd.org/wg.4
2. https://man.openbsd.org/ifconfig.8#WIREGUARD
3. https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
With OpenBSD you will typically end up with a hostname.wgN config that looks like this:
inet6 fd00:abcd:efgh:ijkl::1/48
wgkey <base64-private-key>
wgport 51820
wgpeer <base64-peer-pubkey> \
wgpsk <base64-secret> # optional \
wgaip fd00:abcd:efgh:mnop::1/64 \
wgendpoint x.x.y.y 51820
uphttps://Netbird.io is probably something you may be interested in.
https://news.ycombinator.com/item?id=41327735
> Show HN: Ruroco – like port knocking, but better
Someone opened a PR to address this [1]. It tries to keep it simple in the spirit of the tool, but it adds another dependency (a systemd python module).
I like it overall. The code is so small and simple, it's easy to adapt and to keep small anyway, whatever distro and firewall one might end up use it with.
[0] https://github.com/moxie0/knockknock/blob/bf14bbffc5f1d2105c... [1] https://github.com/moxie0/knockknock/pull/7
Obfuscating your ssh traffic over SSL or Iodine tunnel traffic can punch through many sandbox networks that try to jack secure traffic.
People will argue time constrained tap sequences (think Morse code) are also easily logged with a sniffer, but in general fail2ban rules can email you as the ssh noise should be nearly nonexistent.
i.e. One can determine if a route/VPN is attacking secure traffic links, or has uncanny insight into internal security policy.
Some people post bad policies for setting up ssh, email, and web servers...
Setting up knocking should be the first step on a new server image, as many folks lock themselves out the first run (and on some occasions need to re-image the host). =3
Port Knocking, but the port combination is based on TOTP protocol and has a "use once" feature. Basically rotating protocols :D
Just to prove a point, I made two port knockers using just an UDP packet in a few lines of bash. One uses OpenBSD's signify to sign unlock requests, and the other is on the server side just nftables config to check a static UDP packet, not even a binary.
https://github.com/ThomasHabets/udportknock/blob/master/gen-... Modulating TCP SYN packets? Eyeroll.
Whatever layers of defense you already have in front of your ssh server, port knocking makes it (very slightly) safer.
If knock/knockd were fragile or complex then you’d need to carefully weigh that benefit against increased fragility.
But it’s not. You get the benefit at no real cost.
(I speak of the knock binary in FreeBSD ports - I have no experience with this weird python one …)
Modulating SYN packets is stupid.
Port knocking by sending a secret to the server, in a very simple protocol (to the point of being obviously correct), is good. Once it gets too complex, the implementation is more likely to have a bug than OpenSSH.
So just send that secret in a UDP packet. Modulating SYN packets is like sending your password (or other secret) in morse code rather than ASCII, for no reason.
I elaborated more in https://news.ycombinator.com/item?id=41389167
Sure, many portknocking projects are non-replayable (including the other script in the one I linked to, using OpenBSD's Signify).
But what I'm saying is that OTP or not, it's sent in plain text. But "port knocking" is usually this silly modulation over SYN packets.
I mean that an OTP sent in plain text is still sent in plain text. Using a series of SYN packets is no more encrypted than just sending it as a UDP packet. SYN modulation is not encryption.
Of course non-replayable is better than replayable. I'm not objecting to that. I'm objecting to modulating over SYN packets.
spiped has been another tool sometimes recommended for addressing this and seems more maintained.