SSHd now uses socket-based activation (Ubuntu 22.10 and later)

Thanks @geenat for your comment.
It took me like an hour trying to figure out why I couldn’t set a custom SSH port, then read about the “issue” and then get the official revert commands to work. The official documentation in regards to reverting is pretty much worthless, as it only mentions 3 out of 5 steps, and have I not found this thread I’d still be wondering what I’m doing wrong.

1 Like

How does SSHd on socket respond with Cockpit installed? As remote server connections with Cockpit are handled by SSHd, cause if Cockpit is expecting it as a service then well, YIKES if it doesn’t start in time by socket.

I hope fixes are in place upstream for Cockpit as this is software which can likely be irritated by this change.

I can confirm this does NOT work when running in a container. The transient directory /run/sshd is NOT getting created in the start process and therefore sshd dies on boot.

The place to report bugs against the package is https://bugs.launchpad.net/ubuntu/+source/openssh/+filebug (or using ‘ubuntu-bug openssh-server’).

The /run directory is created by /usr/lib/tmpfiles.d/openssh-server.conf and this has been verified to work in containers.

The README.Debian in openssh-server has been updated as of version 1:9.3p1-1ubuntu1 in mantic to include a complete and up-to-date set of instructions for reverting socket-based activation.

Point taken however that the README is wrong in existing stable releases, and this post pointed to that README. Post updated to detail the correct steps, instead.

In the end this worked for me.
https://askubuntu.com/questions/1483893/unable-to-change-ssh-port-on-ubuntu
Edit /etc/systemd/system/sockets.target.wants/ssh.socket .
then amend

[Socket]
ListenStream=2222
Accept=no

In 24.04 LTS it should be sufficient to declare your ports in sshd.conf.

1 Like