On 22.08.26 12:55, Timo Weingärtner wrote:
Have you thought about using either of:
- raising limits, allowing pubkey auth only and not caring about log spam,
   maybe also lowering LoginGraceTime
- dynamic firewalling (port knocking or something simpler)
- IPSEC AH for ssh access

Hi Timo,

thank you for your useful reply.

We have tried most of these over the years, and we still use some. For
our home machines, behind the usual dynamic address and NAT, a VPN is
the method of choice; we run WireGuard, and OpenVPN before it. IPsec AH
is not an option there, because AH covers the IP header and NAT breaks
it outright.

What all these external mechanisms share is that the gate sits somewhere
you can lock yourself out of, and that combining two of them multiplies
the ways in which that can happen. One wrong line in one configuration
and reachability is gone.

sshd has always been careful about this, and the care is easy to
overlook because it is so well established. You can reinstall or
restart the daemon while you are logged in: your session is an already
forked child and carries on undisturbed. From a second terminal you
then try a new login, and if it fails, the connection you are sitting
in is still there. I have done this often enough to rely on it. Test
first, keep the lifeline, commit afterwards.

That property is what I want to keep, and it is why the admission filter
sits inside the daemon rather than beside it. admitsshd forks per
connection in the same way, so replacing it leaves running sessions
alone. Anything in the data path loses that: restarting it takes every
session through it with you.

AdmitSSH does add a secret that has to be in place before it is of any
use. But that is the same class of problem as authorized_keys, which
anyone who has turned off password authentication already deals with
every day, with a routine they already have. It asks an administrator to
learn no new discipline. Port knocking, firewall rules and tunnels do.

The second thing those approaches share is that none of them ever became
a standard tool. Every administrator builds their own arrangement, and
none of the arrangements get standardized and picked up widely.

I thought port knocking was a wonderful invention when it appeared. But
as the ports kept being flooded the implementations grew, and with each
installation one had to think up a new scheme, document it and remember
it. Coupled to firewall rules it becomes intricate and easy to get
wrong. A port sequence is also not much of a secret against someone on
the network path, and getting UDP, or a sequenced set of TCP connects,
out through a client-side firewall is often what fails.

I should add that I am aware of the tunnel-with-a-pre-shared-key
solutions; spiped is the obvious one and it is in Debian. My reason for
not taking that road is the one above. It is a second tool in the data
path, it doubles the number of components whose upgrade can lock you
out, and it cannot be tested the way the daemon itself can: restarting
it takes every session through it with you, including the one that would
have been your way back in. I want a gate, not a tunnel.

You could also have a shim wrapper (like tcpd) around sshd in inetd mode and a
ProxyCommand for ssh to do your pre-handshake. Benefits:
1. transparent for client tools (ansible, rsync, etc.) with a Host/Match
    section in ssh_config
2. less work: no fork needed
3. minimal dependencies: only a low-level crypto library
4. ability to implement in language of choice
5. easy migration from your variant in case you already deployed it
6. independance from next protocol: not limited to ssh

When thinking about 6.: there might already be such (but incompatible,
defeating 5.) solutions.

Your first point is right and I will not argue it away. With a renamed
client, rsync needs -e admitssh, git needs core.sshCommand, ansible
needs ansible_ssh_executable: one setting per tool, where a ProxyCommand
in a Host block would cost one setting altogether.

The two need not be alternatives, though. It would be possible to create
a ProxyCommand helper so that clients could go on using ssh itself;
after the initial exchange the stock client handles the protocol just as
well, because from there on there is no difference.

On the work: what was laborious was the one-time rename of the tree and
the build system, and testing that the packages coexist with the openssh
ones. That is done. What remains is two self-contained files with short
bindings in sshd.c and sshconnect.c, which I can keep in step with your
releases.

One remark on inetd, because that is where the two shapes differ in
cost. A shim under inetd has to be forked and executed before it can say
no; in the listener an unadmitted client costs one read and one
comparison and no process at all, which on slow machines under scan load
is the whole of the benefit. A standalone gate daemon passing the
accepted socket to sshd would keep that, and sessions would survive its
restart. That may be the shape this converges on.

Either way, this should be an offer to people who want that style of
tool, not something imposed on anyone. What I would like to find is a
way of hosting the repository that is useful to package maintainers of
the common distributions; for Debian I would take on that work myself,
since we build Debian packages for our own tools in any case. Is there a
hosting arrangement you would recommend?

Regards,

Claus

Reply via email to