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
  • 11
  • 5
  • Are the client and server on the same network, or a different one? are you trying to connect using a LAN IP or a WAN IP (or hostname)? – steeldriver Oct 18 '17 at 23:10
  • I'm using Putty for SSH on my home computer to connect remotely with a Dreamhost server on the other side of the country. I'm trying to connect to the server's public IP address (hostname). It worked on port 22, but not on 53425. – peppy Oct 18 '17 at 23:16
  • 1
    Is the server hosted on Dreamhost? If so, I would contact Dreamhost about the port forwarding then. – Terrance Oct 18 '17 at 23:43
  • It's a DreamCompute virtual cloud server. They allow you to install Ubuntu and everything from scratch (not like a shared/managed VPS type thing). Dreamhost says for cloud, it's my job to manage everything (which I am learning to do right now). – peppy Oct 19 '17 at 00:23
  • Do you have anyway right now to access your server at all? – Terrance Oct 19 '17 at 02:14
  • IMO you should stay with port 22, it just makes life easier. Changing ports does not in any way hide your ssh server or increase security, all the scanning tools will recognize the open port and it does not take much to determine it is ssh. It may quiet the logs, but, IMO, there are better ways to secure ssh and quiet the logs. – Panther Oct 19 '17 at 04:59
  • Thanks for the responses. I contacted Dreamhost about it and they have something called "Security Groups", which I guess is something special for cloud-specific servers (even though I have to manage the rest of the server myself). – peppy Oct 22 '17 at 22:19

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
  • 1
  • 2