0

I'm trying to set up a non-standard SSH port (for example: 53425) instead of the default port 22 - on Ubuntu Server 16.04. For some reason, I can't SSH into the server via Putty. Here is what I've done:

  1. I edited the /etc/ssh/sshd_config file and changed the port to 53425.
  2. I restarted the sshd service to update the changes.
  3. I installed UFW and allowed port 53425.
  4. I reloaded UFW and rebooted computer.
  5. I looked into the logs /var/log/auth.log and confirmed "Server listening on 0.0.0.0 port 53425.
  6. I updated Putty to connect to port 53425 instead of 22.
  7. Nothing happens, no login prompt, and a timeout connection error appears.

It seems like it should be really simple, but for some reason it's not working. Am I doing something wrong here?

Thanks Kind regards

peppy
  • 31

1 Answers1

0

I guess it is because when you reboot the server, ssh resets to port 22 until you restart ssh server again using sudo systemctl restart sshd. The way to stop this from resetting is modifying ssh socket file in systemd directory. try the following:

See this post for similar case: SSH resets to default port on reboot

mkdir /lib/systemd/system/ssh.socket.d
sudo nano /lib/systemd/system/ssh.socket.d/port.conf

Paste (replace 54747 with custom port:

[Socket]
ListenStream=
ListenStream=54747

Reboot the server after making changes or run the following:

sudo systemctl daemon-reload
sudo systemctl restart ssh
sudo systemctl restart sshd
MRK
  • 11