Error changed ssh port

SYSTEM INFORMATION
OS type and version Ubuntu 20.04
Webmin version Latest

I try to change ssh port on our webserver ubuntu 20.04. but get this error

ssh: connect to host 184.174.32.123 port 22: Connection refused correct
ssh: connect to host 184.174.32.123 port 6345: No route to host

What do I do wrong
The port is open in fw and have also tested with disabled fw. Same problem

Does your provider also have a firewall ? If so you need to open the port there also

They have no firewall

Very unusual

Well its contabo and I called them and asked

The nmap gived this, meaning it is open but filtered. But where

PORT STATE SERVICE
6345/tcp filtered unknown

What do you perceive ‘no route to host’ means ? Just saying

Well no one can tell me that. Not the support at the host, not serverfault, not chatgpt. So you explain to me.
For me it seems that for some reason its not allowed to change to any other port. The connetion to the server is there, but whatever I do it cant be done over anythin g else than 22

netstat -ap |grep 6345

empty nothing

Maybe you did not restart the ssh server but I would just ask contabo to open the port for you

No its restarted more then once. And I have tried with different ports, changed that in webmin, changed in sshd_conf but nothing works

Is ssh running? Unless you added that port to services you should see it by port number instead of name.

tcp        0      0 0.0.0.0:submissions     0.0.0.0:*               LISTEN      3149482/master      
tcp        0      0 0.0.0.0:8082            0.0.0.0:*               LISTEN      2608912/docker-prox 

systemctl status ssh

sh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2025-01-27 10:23:53 CET; 5h 19min ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1718146 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 1752517 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 1752518 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 1718156 (sshd)
Tasks: 1 (limit: 7056)
Memory: 8.1M
CGroup: /system.slice/ssh.service
└─1718156 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

Can the empty result be because I changed back to 22 to be able to reach the server

Try grepping ssh instead. I wonder if it is picking up the port number properly.

root@main:~# netstat -ap  |grep ssh
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      823/sshd: /usr/sbin 

Note. I’ve added an alternate port to /etc/services show it shows up by name instead of number.

cp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1718156/sshd: /usr/
tcp 0 36 jv80.se:ssh 185.98.107.220:41284 ESTABLISHED 1752670/sshd: root@
tcp6 0 0 [::]:ssh [::]:* LISTEN 1718156/sshd: /usr/
unix 2 [ ACC ] STREAM LISTENING 53739774 1752693/systemd /run/user/0/gnupg/S.gpg-agent.ssh
unix 2 [ ACC ] STREAM LISTENING 51839597 1453071/gpg-agent /root/.gnupg/S.gpg-agent.ssh
unix 2 STREAM CONNECTED 53738162 1752670/sshd: root@
unix 3 STREAM CONNECTED 53402608 1718156/sshd: /usr/
unix 2 DGRAM 53739076 1752670/sshd: root@
root@jv80:~#

Missed this. But, yes. It needs to be on the new port to do the checks. You can use a terminal in webmin to access these commands as an alternative while testing the new port.

tcp 0 0 0.0.0.0:6345 0.0.0.0:* LISTEN 1718156/sshd: /usr/
tcp6 0 0 [::]:6345 [::]:* LISTEN 1718156/sshd: /usr/

ssh: connect to host 184.174.32.123 port 6345: No route to host