Score:1

SSH configured ports not working

us flag

Just installed Kubunut 22.10. I configured my /etc/ssh/sshd_config with a custom port.

# Snip
Port 5555
AllowUsers bob
# Snip

Then restart the daemon to refresh the configuration:

sudo ufw allow 5555

sudo systemctl restart ssh

Everything else is default. I have been doing this configuration setup for a decade. Now when I have another system that cannot connect to it. I get the message:

ssh -p 5555 bob@192.168.254.11

I get the error message:

ssh: connect to host 192.168.254.11 port 5555: Connection refused

If I use the default use the default port 22 the connection works. I have rebooted and the problem persists. I have turned-off / disabled ufw. I have tested with both passwords and SSH-keys, but the connection is refused if I don't use the port 22.

Please help? I don't understand why this suddenly broke.

hr flag
It's likely the socket-based activation rather than a firewall issue - see [SSH default port not changing (Ubuntu 22.10)](https://askubuntu.com/a/1439482/178692)
C.D. avatar
us flag
@steeldriver That is very insightful and helpful! Thank you.
cyberbrain avatar
cn flag
Did you try to enable ufw logging and have a look inside /var/log/ufw.log?
Score:0
us flag

I followed the instructions in this thread SSH default port not changing (Ubuntu 22.10), and they did not work until I did one extra step.

I followed the steps from others but nothing worked,... until I uninstalled openssh-server and then reinstalled it, along with ssh.

  1. mkdir -p /etc/systemd/system/ssh.socket.d
  2. nano /etc/systemd/system/ssh.socket.d/listen.conf
[Socket]
ListenStream=
ListenStream=1234
  1. sudo apt remove --purge openssh-server
  2. sudo apt install openssh-server ssh
  3. sudo systemctl daemon-reload
  4. sudo systemctl restart ssh

After this, running sudo systemctl status ssh should show you are listening on the ports originally setup.

Feb 21 19:28:08 Computer systemd[1]: Starting OpenBSD Secure Shell server...
Feb 21 19:28:08 Computer sshd[48455]: Server listening on :: port 1234.
Feb 21 19:28:08 Computer systemd[1]: Started OpenBSD Secure Shell server.

I do not understand why but I wonder if there was some daemon that did not want to be restarted/reloaded or killed, but uninstalling and reinstalling forced that and therefore picked up the new configuration changes.

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.