3

I am using putty to connect to my Ubuntu 16.04 VPS.

I decided to change the default SSH port from 22 to 443. I did this changing the line

Port 22

in /etc/ssh/sshd_config

to Port 443

Now when I am trying to connect to the server using port 443 I get the error saying "Server unexpectedly closed network connection"

When I try to connect to the server using port 22 I get the error saying "Network error: Connection refused"

The server is up and running I just cannot connect to it anymore, is there anyway to fix this?

EDIT: I reinstalled the VPS and reconfigured it again. The possible issue that might have caused this could be that I used the same port to connect to my VPS using Putty and to use that same port for my proxy in squid.

closed as off-topic by Jenny D, kasperd, Tommiie, Ward Mar 12 at 4:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should demonstrate reasonable business information technology management practices. Questions that relate to unsupported hardware or software platforms or unmaintained environments may not be suitable for Server Fault - see the help center." – Jenny D, kasperd, Tommiie, Ward
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Don't bother changing the ssh port. It doesn't make you more secure, but it does give you a false sense of security. It also gives you lots of problems if you are new. – Michael Hampton Mar 10 at 13:56
  • Thank you, but I have fixed it already. My reason is to make my proxy as anonymous as possible, when port 22 is open websites can see that and that is an indication of proxy – shiu'sho Mar 10 at 15:02
  • 2
    Having port 22 open does not indicate a proxy. – Michael Hampton Mar 10 at 15:18
  • Might be, I do now know, I am just trying to set up an anonmous proxy and I am using whatleaks.com to check what I need to take care of. Does Passive OS fingerprints different than Browser Agent indicate a proxy? – shiu'sho Mar 10 at 17:08
  • You can't use the same port for two separate services. If you do want to use another port than 22, use one that's not already in use by something else. – Jenny D Mar 13 at 14:26
5

is there anyway to fix this?

  • Use the system console (out of band connection) if available.
  • Use the VPS recovery boot to mount the VPS disk and then edit the sshd_config file to reset the port to 22 from 443.

Less optimally

  • Boot a new VPS instance, configure as per the first instance using your configuration management tools and recover from backups.
  • Thank you for your reply @Iain. I rebooted my VPS in rescue mode and was able to connect to it in that mode, but when I go to /etc/ssh/sshd_config I am seeing #Port 22 and not Port 443 It means that I cannot access the original file, the one in recovery mode is somehow different – shiu'sho Mar 10 at 8:52
  • You will need to mount the root partition/lv/whatever into the recovery environment. Your VPS host should provide information on how to do that. – Iain Mar 10 at 20:21
0

You probably have forgotten to add port 443 to firewall (ufw). Make console connection if possible, otherwise your VPS provider can help you.

  • I am reading now about UFW and it says that by default it is disabled, so I guess that is not the case, anyway, could you provide the instructions how to add the port to UFW please? If you could, please be as much clear with every step as possible since it is my day 3 in Linux. Thanks! – shiu'sho Mar 10 at 8:20
-1
  1. Verify your sshd service is running, netstat to check which port is it listening
  2. Verify your port being added to firewall
  3. Check logs from /car/log/messages to see if any messages tells you about it.
  4. While you connect, try to use -vvv option to know more info on it
  5. Try to see if ssh -p 443 root@othrhost works

Not the answer you're looking for? Browse other questions tagged or ask your own question.