当前位置:首页 > 站长知识 > 服务器 > 正文内容

如何重启 CentOS 8 中的 SSH 服务

2024-11-27服务器48

重启 SSH 服务的命令:

1

systemctl restart sshd

步骤详解:

  1. 访问终端:使用 SSH 或本地终端连接到您的 CentOS 8 服务器。

  2. 输入命令:键入以下命令并按 Enter:

    1

    systemctl restart sshd

  3. 验证服务状态:等待命令执行完毕后,使用以下命令验证 SSH 服务是否正在运行:

    1

    systemctl status sshd

输出应如下所示:

1

2

3

4

5

Active: active (running) since Wed 2023-01-04 13:03:14 PST; 15min ago

Main PID: 868 (sshd)

CGroup: /system.slice/system-ssh.slice/ssh.service

           ├─868 /usr/sbin/sshd -D

           └─1016 ssh-agent /usr/bin/dbus-launch --exit-with-session --nofork dbus-uuid=6b1a38d5e46340c1845a2cbfa0c5463f --sh-syntax --close-stderr

说明:

  • systemctl restart sshd 命令将重新启动 SSH 服务。

  • systemctl status sshd 命令将显示 SSH 服务的状态。

  • 如果服务未运行,您可以使用 systemctl start sshd 命令启动它。