1

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.

C.D.
  • 369

1 Answers1

0

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.

C.D.
  • 369