Live data from Hacker News

I close SSH port 22 (and what I use instead)

michelebologna.net

31–40 of 106 posts

Re: I close SSH port 22 (and what I use instead)

#31
post #4

Is this actually practically reducing the attack surface? We're replacing a battle hardened service with a random one that has the ability to manipulate the firewall rules.

I think the answer is yes. A response from a remote system (or lack of) is a signal. The conventional ssh protocol method when connecting to a server is to instantly send over the identification string. RFC 4253 requires "both sides MUST send an identification string". It doesn't necessarily decide an order, but most ssh implementations I've seen send their protocol string before any other data has been received.

The broadcasting of the versioning information does constitute a potential leakage of information that could be useful to an attacker. Even if we contrast this to something like mTLS, the client certificate doesn't come until fairly late in the handshake, so there is still information that can be cleaned from the ServerHello from an unauthenticated inspector. This is also the case with QUIC since it piggybacks off the general TLS handshake.

I think the issue is, for a known set of systems, can you create communications between them that are oblivious/non-discoverable to non-authorized systems. I think the answer is yes, but it requires an out-of-band key agreement protocol. Wireguard is an example. However, the problem of out-of-band key agreement can't really be ignored.

I think the article's method is somewhat valid. I also think it is non-ideal for only doing source IP based rulesets, especially in the world of IPv4 and NAT being prevalent.

Re: I close SSH port 22 (and what I use instead)

#32

> If a zero-day drops in OpenSSH... Realistically, fwknop is more likely to have a vuln than OpenSHH. Last release was two years ago and the readme dates back twelve :/ Time will tell.

Seriously. If a zero-day drops in OpenSSH, it's quite literally the end of the world.

Re: I close SSH port 22 (and what I use instead)

#33
post #27

What I do is laughably simple. 1. Disable all logging about break-in attempts. 2. Do not have any common user names like "root". Say you want to be able to log in as root from anywhere, just with a password. This is a wise idea; what if you need access, but are in a situation where you are not able to use a certificate? Make up an alternative name like roto-rooter or whatever pops into your head. Install it into the…

This is a bad idea™. You should never have more than one UID 0 on a Unix system. This will violate most corporate security guidelines (STIG and CIS) * . And for good reason. A much better idea is to set up a non-root user and configure sudo correctly. * https://www.stigviewer.com/stigs/red_hat_enterprise_linux_9/...

I am not a corporation, so I don't need corporate guidelines.

There isn't more than one UID 0. Only more than one password/shadow database entry pointing to it.

(It might not be necessary; perhaps there is a way for OpenSSH to remap names, so that our example rotorooter is mapped to root by sshd itself.)

> A much better idea is to set up a non-root user and configure sudo correctly.

Even if so, the same principle applies: do not call that user admin, for instance. Don't use your first name or anything that a targeted, non-random attacker could guess about you.

If that user's name is, oh, 7yMfAxB6, it will never be probed. Though no need to be that paranoid.

From the document:

> Multiple accounts with a UID of "0" afford more opportunity for potential intruders to guess a password for a privileged account.

Whoever wrote that does not know WTF they are talking about. Two identical entries in passwd/shadow do not comprise different "accounts".

The UID is the account; the password DB is more or less just window dressing.

If the two shadow entries have exactly the same password hash, then no, there aren't more opportunities to guess a password.

The only problem with the scheme in a multi-user institutional context is that when an additional UID 0 entry appears that is not "root", it looks like a backdoor someone planted to give themselves continued root access.

I don't think it's applicable to what I'm talking about because an institution probably shouldn't be setting up password-based SSH access to a renamed root account over the public internet. This is something that's a good solution for individuals or very small operators.

> Change the UID of any account on the system, other than root, that has a UID of "0".

Change it to what, with what desired effect? Might as well say 'oh, screw with the password file randomly for shits and giggles'.

Better idea: investigate why there is another 0. Maybe there is a good reason.

Re: I close SSH port 22 (and what I use instead)

#35
post #27

What I do is laughably simple. 1. Disable all logging about break-in attempts. 2. Do not have any common user names like "root". Say you want to be able to log in as root from anywhere, just with a password. This is a wise idea; what if you need access, but are in a situation where you are not able to use a certificate? Make up an alternative name like roto-rooter or whatever pops into your head. Install it into the…

This is a bad idea™. You should never have more than one UID 0 on a Unix system. This will violate most corporate security guidelines (STIG and CIS) * . And for good reason. A much better idea is to set up a non-root user and configure sudo correctly. * https://www.stigviewer.com/stigs/red_hat_enterprise_linux_9/...

[deleted]

Re: I close SSH port 22 (and what I use instead)

#38

> If a zero-day drops in OpenSSH... Realistically, fwknop is more likely to have a vuln than OpenSHH. Last release was two years ago and the readme dates back twelve :/ Time will tell.

fwknop is a bit lower risk though. If all an attacker can do is open a port, they’ll still have to exploit OpenSSH.

Re: I close SSH port 22 (and what I use instead)

#40
post #28

Port knocking, and other bespoke middle layers in front of internet services, is stupid. It violates Kerckhoffs’s principle¹. If you want more secret bits which users need to know in order to access your system, increase your password lengths, or cryptographic key sizes. If you want to keep log sizes (or “noise”) manageable, adjust your logging levels. Anything added in front of your normal service also complicates a…

I agree port knocking is a direct violation of Kerckhoff's principle. However, the proposed solution has non-discoverability from unauthorized sources which isn't necessarily in the threat model of OpenSSH or general cryptography. I do feel like this is potentially a desirable trait. I elaborated a bit more here[0], but I'm curious if you have any grander thoughts on how this could be approached

[0]: https://news.ycombinator.com/item?id=49307986

Post reply on HN