我目前正在使用 Orange Pi 进行一些测试。在全新安装上进行更新后,ssh 服务器似乎不再能够自行启动,而且我也无法手动启动它。清除并重新安装 openssh-server 重新安装后仍然出现相同的错误
错误:
setting up openssh-server (1:7.2p2-4ubuntu2.6) ...
Failed to validate path /var/run/sshd: Bad file descriptor
Job for ssh.service failed because the control process exited with error
code. See "systemctl status ssh.service" and "journalctl -xe" for details.
invoke-rc.d: initscript ssh, action "start" failed.
ssh.service - OpenBSD Secure Shell Server
loaded: loaded (/lib/systemd/system/ssh.service; enabled;vendor preset: enabled)
Active: activating (auto-restart) (result: exit code) since WED 2018-11-21 11:01:38; 59ms ago
Process: 6423 ExecStartPre=/usr/bin/sshd -t (code=exited, status=255)
Failed to start OpenBSD Secure Shell....
ssh.service: Unit Entered Failed state.
ssh.service: Failed with result 'exit code'
dpkg: error processing package openssh-server (--configure):
sub-process installed post-installation script returned aroor exit status 1
errors were encountered while processing: openssh-server
ssh.conf:
# ssh - OpenBSD Secure Shell server
#
# The OpenSSH server provides secure shell access to the system.
description "OpenSSH server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
umask 022
env SSH_SIGSTOP=1
expect stop
# 'sshd -D' leaks stderr and confuses things in conjunction with 'console
log'
console none
pre-start script
test -x /usr/sbin/sshd || { stop; exit 0; }
test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; }
mkdir -p -m0755 /var/run/sshd
end script
# if you used to set SSHD_OPTS in /etc/default/ssh, you can change the
# 'exec' line here instead
exec /usr/sbin/sshd -D
无论出于何种原因,配置文件都没有创建目录
答案1
好吧,我自己也玩了一下。事实证明,文件系统喜欢在启动时清理 /var/run/sshd 。我现在的修复是制作了一个 bash 脚本来在启动时创建该目录,然后启动 ssh 服务。它现在似乎有效,尽管可能有一种我不熟悉的更快的方法。