关于sshd服务无法开启的问题集合

SSHD服务开启问题集合

报错1

  • 错误
:~$ systemctl restart sshd
Failed to restart sshd.service: Interactive authentication required.
See system logs and 'systemctl status sshd.service' for details.
  • 解决:
sudo systemctl enable ssh.service

错误2

  • 错误
:~$ sudo sshd -t
/etc/ssh/sshd_config: No such file or directory
  • 解决:
添加对应的/etc/ssh/sshd_config

错误3

  • 错误
:~$ sudo sshd -t
Privilege separation user sshd does not exist
  • 解决:
sudo useradd --system sshd
sudo vim /etc/passwd (选择好对应的sshd路径,sshd:x:997:997::/usr/sbin/sshd:/bin/sh)

错误4

  • 错误
:~$ sudo sshd -t
sshd: no hostkeys available -- exiting.
  • 解决:
:~$ sudo ssh-keygen -A
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519

错误5

  • 错误
:~$ sudo sshd -t
Missing privilege separation directory: /run/sshd
  • 解决:
@:~$ sudo service sshd start
@:~$ systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-07-10 13:12:31 CST; 35s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 3680 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 3681 (sshd)
      Tasks: 1 (limit: 9487)
     Memory: 1.0M
     CGroup: /system.slice/ssh.service
             └─3681 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

Jul 10 13:12:31 DESKTOP-SL9RQUV systemd[1]: Starting OpenBSD Secure Shell server...
Jul 10 13:12:31 DESKTOP-SL9RQUV sshd[3681]: Server listening on 0.0.0.0 port 22.
Jul 10 13:12:31 DESKTOP-SL9RQUV sshd[3681]: Server listening on :: port 22.
Jul 10 13:12:31 DESKTOP-SL9RQUV systemd[1]: Started OpenBSD Secure Shell server.

你可能感兴趣的:(网络,linux,运维)