我究竟做错了什么?
我添加了/etc/ssh/sshd_config
:
Host myserver
HostName xxx.xxx.xxx.xxx
User myuser
Port 22
- 当我尝试重新启动时
sshd
,收到错误:$ sudo systemctl restart sshd Job for ssh.service failed because the control process exited with error code. See "systemctl status ssh.service" and "journalctl -xe" for details.
- 是否有语法错误
sshd_config
?$ systemctl status ssh.service ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2023-07-31 14:08:15 EDT; 3min 31s ago Docs: man:sshd(8) man:sshd_config(5) Process: 1780 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255/EXCEPTION) CPU: 3ms
$ journalctl -xe My-VM sudo[1772]: myuser : TTY=pts/0 ; PWD=/var/www/example.com ; USER=root ; COMMAND=/usr/b> My-VM sudo[1772]: pam_unix(sudo:session): session opened for user root(uid=0) by myuser(uid=1000) My-VM sudo[1772]: pam_unix(sudo:session): session closed for user root
答案1
您的主机配置适用于客户端,而不是服务器,因此将其放在客户端配置文件中;通常:$HOME/.ssh/config
- 这将告诉您服务器配置文件中是否存在任何语法错误;通常是:
/etc/ssh/sshd_config
sudo sshd -t