I want to answer this in case someone else is going through the same madness I was yesterday morning. Found very little information on the internet so I want to share this with you here.
Before getting into the guide I want to thank Phanaz whose answer on serverfault helped crack the answer to this riddle.
If Google or GPT haven't helped, I hope this does!
I assume that you already tried to change your port in ssh_cofnig
, sshd_config
and it hasn't worked. That's because Ubuntu 24.04 want's things done differently and I'm not going to pretend I know why.
Comment out the port section for starters if you have them uncommented.
Instead go to
/etc/systemd/system/sockets.target.wants
In there you should have the ssh.socket
.
Edit ssh.socket
with sudo nano or whatever your favourite editor. You should see:
[Unit]
Description=OpenBSD Secure Shell server socket
Before=sockets.target ssh.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Socket]
ListenStream=2469
Accept=no
FreeBind=yes
[Install]
WantedBy=sockets.target
RequiredBy=ssh.service
Change this to:
[Unit]
Description=OpenBSD Secure Shell server socket
Before=sockets.target ssh.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Socket]
ListenStream=
ListenStream=2469
Accept=no
FreeBind=yes
[Install]
WantedBy=sockets.target
RequiredBy=ssh.service
Now save the file and update the daemon by running systemctl daemon-reload
.
Then systemctl restart ssh.socket
to finalise everything.
Try in the reverse order e.g. systemctl restart ssh.socket
then systemctl daemon-reload
if you get any errors. It was very early morning and my notes are unclear.
Finally check with systemctl status ssh.socket
- if it shows running and enabled, the rest of your ssh configuration is also fine, this should work.
This worked for me and I hope it does for you too. First time I write in a forum. Always thought it was for crazies and maybe I am a crazy after this debacle. But I don't want anyone else going through this, Cursing Google, GPT and their life at 4 in the morning.
Cheers 🍻
Top comments (1)
very gud very well done