Score:0

How to change the ssh port on Ubuntu 23.04?

fi flag

How to change the ssh port on Ubuntu 23.04?

root@ubuntu:/home/user# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.04
Release:        23.04
Codename:       lunar
Bodo avatar
pt flag
Please [edit] your question and explain what you want to achieve. If you want/need to use a different port number at your public IP address, you could configure this in the port forwarding of your router.
muru avatar
us flag
Does this answer your question? [SSH default port not changing (Ubuntu 22.10)](https://askubuntu.com/questions/1439461/ssh-default-port-not-changing-ubuntu-22-10)
Score:0
eg flag

In Ubuntu 22 and mostly in Ubuntu 23 if we change ssh port in sshd_config it doesn't work so I figured it out following method

sudo vim /lib/systemd/system/ssh.socket

Change the following parameter to the port of your choice e.g. 1122

ListenStream=1122

Save the file and quit the vim editor with the command wq! and then execute the following commands one by one

This will reload the daemon

sudo systemctl daemon-reload  

To restart the SSH server

sudo systemctl restart ssh     

and if you want to check the port you can check with the following command netstat -ant |grep 6381

in case you you face the error Command 'netstat' not found

you can be installed with: apt install net-tools -y

muru avatar
us flag
Any edits to `/lib/systemd/system/ssh.socket` will be lost when the package is updated. Use override files to change settings instead.
Muhammad Irfan Aslam avatar
eg flag
which files i tried updating in `/etc/ssh/sshd_config` but didn't worked
muru avatar
us flag
See the duplicate: https://askubuntu.com/questions/1439461/ssh-default-port-not-changing-ubuntu-22-10
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.