Find best webhosting in chennai

Location

Chennai

Working Hours

09:00 AM to 07:00 PM ( Mon - Sat )

Phone Number

(+91) 9884800300

SSH default port not changing (Ubuntu 22.10 and later)

In this article to came to know fix or solution, SSH default port not changing in ubuntu 22.10 or latest version.

Basically all administrator known about the SSH default change process and how to do change it. This can be done via,

Edited /etc/ssh/sshd_config, left the default #Port 22 line but added Port 1234 below it.

Then added allow rule for it in UFW using the command:

sudo ufw allow 1234

Now restart the SSH service it will work.

In few cases if the SSH port change was not reflected or not worked on Ubuntu 22.10 and Ubuntu 24 or later version).

Below is the fix and steps to resolve SSH default port not changing issue.

Login to SSH or Terminal,

$ sudo nano /etc/ssh/sshd_config

Modify the port 1234

save it, quit.

SHd now uses socket-based activation Ubuntu 22.10 or later. Read more about this change being

your options for changing 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=
ListenStream=1234
EOF

sudo systemctl daemon-reload
sudo systemctl restart ssh.socket

It should then state it’s started listening on the new port: systemctl status ssh.

SSH default port not changing

Now you should be able to see that the port 1234 is open.

Do not forget to open the port on firewall e.g. ufw.

sudo ufw allow 44022

I suggest you open another putty session to ensure you are able to login.

That’s it you came to know how to fix if SSH default port not changing. If you need to know restoring CSF firewall configuration from backup click here.