I am trying to change the SSH port on a VPS using Almalinux. I followed this guide but have not been able to.
These are the output I receive when try to SSH using both 22 and the new port respectively.
ssh: connect to host XXX.XXX.XXX.XXX port 22: Connection timed out
ssh: connect to host XXX.XXX.XXX.XXX port 23498: Connection timed out
Here is the port declaration in my /etc/ssh/sshd_config
.
...
Port 23498 22
...
Running semanage port -l | grep ssh
gives the following output.
ssh_port_t tcp 23498, 22
Restarting using service sshd restart
with the new port yields the following output.
Redirecting to /bin/systemctl restart sshd.service
Job for sshd.service failed because the control process exited with error code.
See "systemctl status sshd.service" and "journalctl -xe" for details.
Here is the output of systemctl status sshd.service
.
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2022-02-25 17:26:08 CET; 34s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 25872 ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY (code=exited, status=255)
Main PID: 25872 (code=exited, status=255)
Feb 25 17:26:08 xxx.xxx.xxx systemd[1]: sshd.service: Main process exited, code=exited, status=255/n/a
Feb 25 17:26:08 xxx.xxx.xxx systemd[1]: sshd.service: Failed with result 'exit-code'.
Feb 25 17:26:08 xxx.xxx.xxx systemd[1]: Failed to start OpenSSH server daemon.
Changing the port causes normal SSH to break as well. Commenting out the Port
in the sshd_config
and restarting sshd
allows access via SSH again. I have also tried reinstalling the openssh-server
after changing the ports but to no avail. The ports are allowed through the uncomplicated firewall. Any help is highly appreciated.