Skip to main content

Ubuntu : Change default SSH Port

By January 7, 2024Server Admin

Changing the port in “/etc/ssh/sshd_config” no longer works.

The port can be changed in ‘/lib/systemd/system/ssh.socket’ but that won’t survive SSHD update.

Follow these steps:

mkdir /lib/systemd/system/ssh.socket.d

nano /lib/systemd/system/ssh.socket.d/port.conf
[Socket]
ListenStream=
ListenStream=2222

systemctl daemon-reload
systemctl restart ssh
systemctl restart sshd

Verify: netstat -luntp | grep 2222

5 1 vote
Article Rating

Author Dhillon

More posts by Dhillon

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x