SSHd now uses socket-based activation Ubuntu 22.10 or later.
The are unused, now that I read the comments in full I found:/etc/ssh/sshd_config
# Port and ListenAddress options are not used when sshd is socket-activated,
# which is now the default in Ubuntu. See sshd_config(5) and
# /usr/share/doc/openssh-server/README.Debian.gz for details.
So there are two options for you to change from default port:
-
Turning off this change and reverting to how SSHd worked prior to this update
systemctl disable --now ssh.socket
systemctl enable --now ssh.service
- Then the /etc/ssh/sshd_config works again with Ports and Addresses setting
-
OR Listening socket stream update
-
mkdir -p /etc/systemd/system/ssh.socket.d
-
cat >/etc/systemd/system/ssh.socket.d/listen.conf <<EOF
[Socket] ListenStream=12345 EOF
-
sudo systemctl daemon-reload
-
sudo systemctl restart ssh
-
It should then state it's started listening on the new port: sudo systemctl status ssh
Server listening on 0.0.0.0 port 12345.
Server listening on :: port 12345