For those of you who started using Ubuntu 22.04 Jammy Jellyfish and realized the conventional way of editing /etc/ssh/sshd_config does work. Hope this tutorial is useful and nothing else changes. This works as of Feb 19 2023.
I am not sure when this started but in Ubuntu 22.04 there is this new ssh socket service that you need to change if you want to customized the ssh port.
The quickest way for me to do this is to edit the /lib/systemd/system/ssh.socket, and change the ListenStream=<custom port>
![](https://dracocybersecurity.com/wp-content/uploads/2023/02/image-19-1024x484.png)
Now you not only need to restart the ssh service you need to do the following.
Stop the ssh.service, ssh.socket, do a daemon reload and the restart the service
systemctl stop ssh.service systemctl stop ssh.socket systemctl daemon-reload systemctl start ssh.socket systemctl start ssh.service |
You want to make sure you have a backup ssh session active when you are doing the following changes to avoid locking yourself out or have a script schedule to change the port back if anything goes wrong.