Live data from Hacker News

Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

github.com

81–90 of 200 posts

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#81
post #74

Would this potentially leak consecutive TOTPs to an attacker who connects to all 1,000,000 or so possible addresses at 30 second intervals (and records the one that responds)?

If that were useful, the underlying HMAC would be broken.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#82

There should be no need to do this if you have a properly configured public/private key auth setup and disable password based login. And of course keep up to date on openssh patches and security advisories. I worry that something like this will provide a false sense of security for people who might ignore other more common-sense, fundamental precautions first. Before doing something like this I would worry a lot more…

Yeah I suspect that up to date openssh with a config that passes ssh-audit's checks, with a fail2ban config, along with an ed25519 key unlocked by a yubikey will be entirely adequate security for SSH. Then time would be better spent securing VPNs and reducing internal trust.

Bit like having a front door that would withstand a C4 blast, but now all your windows are shattered.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#83
post #46
post #31

Earlier quoted context omitted.

Doesnt the TOTP in this case concern the listening port for sshd, so it doesnt actually touch the authentication in any way? Just switches the port in a TOTP’esque manner

The point is that if the attacker somehold got hold of the primary login credentials (username + key/password), then they can easily bypass this scheme with a port/address scan. This can be done very quick[1] and is hard to rate limit. Furthermore, an attacker that can eavesdrop on the user's connections can infer the OTP since it's being transmitted in the open., but if it was done through a PAM module they wouldn't…

there is no "easily bypassing this scheme with a port/address scan" when it comes to ipv6 /64 ranges.

If you could scan 1 million IP addresses a second on a /64 (which is absurd), it would take 600K years to scan a full /64.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#84
I prefer single packet auth with pyknock [1]. SSH config from client side looks like this:

  Host vm vm-0 vm-0.com
      User user
      HostName vm-0.com
      ProxyCommand sh -c "pyknock-client -s 0.0.0.0 -S \"\$(myip)\" open %h "$(pass my/pyknock/%h)" && sleep 1 && exec nc -4 %h %p"
      Port 1792
Where `myip` [2] is an small utility which reliably detects my external IP address.

[1] https://github.com/Snawoot/pyknock/

[2] https://github.com/Snawoot/myip

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#85
post #37

This reminds of port knocking. Could be useful if you are really annoyed by those script kiddos, but in essence this is security by obscurity.

I don't think port knocking is security by obscurity. It is another layer of secret that must be known (or guessed) to gain access.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#86

Stop it with this cloak and dagger BS. Just set a shared secret on it: https://github.com/google/tcpauth (Yes, MD5 is safe for this use) With tcp MD5 your connection is even secured against an active attacker who can sniff. They can't inject, or even RST the connection. Even if they can sniff and spoof everything.

> Yes, MD5 is safe for this use

Sure, it just begs the question: why in the world would you still try to find nails for the hammer called MD5 when (according to Wikipedia) cryptographers recommended upgrading to SHA-1 in 1996 already? This project's first commit was well, well beyond the deprecation of MD5. It's a bit safer than but also not entirely unlike putting a Windows 7 on the internet just because there are no known exploits in an up-to-date 7 system currently.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#87
post #74

Would this potentially leak consecutive TOTPs to an attacker who connects to all 1,000,000 or so possible addresses at 30 second intervals (and records the one that responds)?

To elaborate a bit on what AlexCoventry already said:

No. The mechanism underpinning TOTP should guarantee that the internal state does not leak from any outputs produced. That is, of course, unless some security flaw is found, but that seems unlikely to ever happen at this point if you use a regular SHA-2-based TOTP. It basically does HMAC_SHA256(secret, time) where the time is known (also to the attacker) but the secret is shared between the two authenticating systems. If you could derive secret from time+output, the mechanism would serve a much more limited purpose. Part of the purpose of TOTP is that an attacker that observed a (number of) login(s) can't predict any future or past tokens for their own use.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#88
post #68
post #22

Earlier quoted context omitted.

Your server has NTP. Your client likely, too, if it has enough network to connect to the server. If it does not use NTP, it's easy to set the time within the minute or so required manually.

Hardware clocks are famously unreliable and inaccurate. NTP has failure modes that can result in servers being wildly out of sync with reality. Letting either one of those hose your ability to log in and diagnose/recover the system is a mistake.

I disagree that requiring the time to be correct precise to 30 seconds is "a mistake" in the general case, but it is a good point that this might happen in some weird edge case (where also changing the local clock +/-60s is not enough to fix it). Having a fallback that lets you in via a mechanism that does not depend on any external factors or uninterrupted power supply does seem like a good idea for important physical infrastructure. (For virtual stuff, in such a weird case you can always just modify the disk image to get ntp from a working host and boot again.)

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#89

That’s a super cool concept, but doesn’t this fall a bit under “security by obscurity”?

In the same way that passwords, private keys, and safe combinations are security by obscurity, sure.

Except that passwords, private keys, and safe combinations cannot be guessed in 0.1 seconds the way that a port can (65k possible values and a SYN packet really isn't large). There is a line to be drawn between high-entropy secrets and using an unpredictable port number.

Re: Tosh: Changing your SSH server's listen address every 30 seconds based on TOTP

#90

That’s a super cool concept, but doesn’t this fall a bit under “security by obscurity”?

It's another layer of security. There have been exploits of OpenSSH in past so this may be prudent.

I actually looked into this a few months ago and if memory serves, the last default setup authentication bypass was in something like 2003. Since then, I think the worst thing has been user enumeration. And 2003 was a very different world in terms of how much we cared about hardening, so ssh being reliable throughout all that time is really quite something.
Post reply on HN