我试图使用Almalinux更改VPS上的SSH端口。我跟踪了这个指南,但一直未能做到。
这些是我分别使用22和新端口尝试SSH时收到的输出。
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这是我的/etc/ssh/sshd_config中的端口声明。
...
Port 23498 22
...运行semanage port -l | grep ssh将提供以下输出。
ssh_port_t tcp 23498, 22使用service sshd restart重新启动新端口将产生以下输出。
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.这是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.更改端口也会导致正常SSH中断。注释掉Port中的sshd_config并重新启动sshd允许再次通过SSH访问。我也尝试过在更改端口后重新安装openssh-server,但没有成功。这些端口被允许通过简单的防火墙。任何帮助都是非常感谢的。
发布于 2022-02-25 16:41:22
Port 23498
Port 22而不是
Port 23498看上去火瓦尔德跑得和ufw一样好。如果没有配置就意味着我的端口被封锁了。
https://serverfault.com/questions/1094791
复制相似问题