Sorry, I was trying to offer the most direct solution, but here is more
detail.

First - unless you have a configuration for the socket that is more
complicated than what can be achieved with the Port, ListenAddress, and
AddressFamily options in sshd_config[1], then I strongly recommend using
e.g. /etc/ssh/sshd_config.d/custom.conf for your port configuration
instead of using ssh.socket overrides.

Second - if you want your /etc/system/systemd/ssh.socket.d/override.conf
to work, you need to specify the address family explicitly, *or*
override the value of BindIPv6Only=ipv6-only [2], too. For a more
detailed explanation, please see bug 2118912 [3].

In other words, because your override is:

# /etc/systemd/system/ssh.socket.d/override.conf
[Socket]
ListenStream=
ListenStream=22

rather than:

# /etc/systemd/system/ssh.socket.d/override.conf
[Socket]
ListenStream=
ListenStream=0.0.0.0:22
ListenStream=[::]:22

or:

# /etc/systemd/system/ssh.socket.d/override.conf
[Socket]
ListenStream=
ListenStream=22
BindIPv6Only=both

you are actually overriding the default ssh.socket unit in a way that
says "only listen on port 22 via IPv6, not IPv4".

Hence, I hope it is clear why I recommend simply using
/etc/ssh/sshd_config.d/custom.conf.

[1] https://manpages.ubuntu.com/manpages/noble/en/man5/sshd_config.5.html
[2] 
https://www.freedesktop.org/software/systemd/man/latest/systemd.socket.html#BindIPv6Only=
[3] https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/2118912

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2122601

Title:
  ssh access on port 22 inhibited

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/2122601/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to