AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-956604

Rashiq's questions

Martin Hope
Rashiq
Asked: 2022-02-26 08:36:36 +0800 CST

无法在存在 selinux 的 Almalinux/CentOS 8 上更改 SSH 端口

  • 0

我正在尝试使用 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更改端口后重新安装,但无济于事。允许端口通过简单的防火墙。非常感谢任何帮助。

linux centos ssh centos8 selinux
  • 1 个回答
  • 477 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve