[SOLVED] Port 22 refuses connection + ssh new port not working anymore

Hardware: VPS bought online ( Contabo )
YunoHost version: (stable)
I have access to my server : Through SSH and browser
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

im trying to sync a directory from my machine to my yunohost servers but, with either scp or rsync i always get the same error:

ssh: connect to host mms.nohost.me port 22: Connection refused

the port is present and open in the firewall section.

anyone can help? :hugs:

sounds like you tried multiple time to connect with incorrect crendentials and got (temporarily) banned by fail2ban …

(Though could be something else too)

it happened since the first attempt, but probably this fail2ban issue is related to this? i received around 10 more similar emails overnight.

or may be because of this:


Base system (basesystem)


[WARNING] There’s been a suspiciously high number of authentication failures recently. You may want to make sure that fail2ban is running and is correctly configured, or use a custom port for SSH as explained in Security | Yunohost Documentation.

i checked already and fail2ban is working.

Change the port

are we talking about the ssh port?
i’ve done that a long time ago.
should i do it again?

i did it anyway, but a couple of warnings came up:

Info: Saving the new configuration...
Success! Configuration updated for 'ssh'
Success! Configuration updated for 'fail2ban'
Warning: Job for ssh.service failed because the control process exited with error code.
Warning: See "systemctl status ssh.service" and "journalctl -xe" for details.
Error: Could not run script: /usr/share/yunohost/hooks/conf_regen/03-ssh
Warning: Some firewall rule commands have failed. More info in log.
Success! Config updated as expected

this it the log.

and eventually the port hasn’t been changed and the “new old” one doesn’t seem to work anymore. :upside_down_face:

Then what does journalctl -u sshd -n 100 --no-pager --no-hostname tells

where should i input it?
because if i run it now in my terminal i get no entries.

Zblerg then lets try systemctl status ssh.service | cat

or also maybe sshd -t

xoxo:~$ systemctl status ssh.service | cat
Unit ssh.service could not be found.
:~$ sshd -t
sshd: no hostkeys available -- exiting.

none of them seem promising…

Hmmm can you confirm that you’re running those on your server and not your own machine …

In the log, I saw you used a port outside the range permitted.

Port numbers range from 0 to 65536

Hmyeah indeed

not on my server because i can’t enter it through ssh anymore…

guess that might have caused the error, but now neither of the two works.

by accessing Tools through the web browsser portal i can get the logs of ssh, which status is failed btw.

Now you 're locked out of your server. I don’t know if you have an emergency access on your vps, that would be helpful to restore the port to 22, restart sshd. Or you can try a terminal app on yunohost.
After you get a working 22 port, change it using Security | Yunohost Documentation
Test it and close port 22

Seems we have a bug here. security.ssh.port must not be in the wrong range

sshd[1268424]: /etc/ssh/sshd_config line 7: Badly formatted port number


1 Like

i do, it gave me root access through ssh but now im not sure how should i restore the port.
i found this online:

rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server

is that correct?