我的服务器操作系统是 Ubuntu 16.04 (LTS)。有一次我使用 apt 安装一些软件。它显示 SSH 服务错误。当我按照说明操作时systemctl status ssh.service
:
root@mqzhang:~# sudo apt-get install nmap
Reading package lists... Done
Building dependency tree
Reading state information... Done
nmap is already the newest version (7.01-2ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 188 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up openssh-server (1:7.2p2-4ubuntu2.8) ...
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 "restart" 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 Fri 2019-09-13 11:47:21 CEST; 11ms ago
Process: 29900 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=1/FAILURE)
Process: 29895 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 29900 (code=exited, status=1/FAILURE)
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Main process exited, code=exited, status=1/FAILURE
Sep 13 11:47:22 mqzhang systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Unit entered failed state.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Failed with result 'exit-code'.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Service hold-off time over, scheduling restart.
Sep 13 11:47:22 mqzhang systemd[1]: Stopped OpenBSD Secure Shell server.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Start request repeated too quickly.
Sep 13 11:47:22 mqzhang systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Unit entered failed state.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Failed with result 'start-limit-hit'.
dpkg: error processing package openssh-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of ssh:
ssh depends on openssh-server (>= 1:7.2p2-4ubuntu2.8); however:
Package openssh-server is not configured yet.
dpkg: error processing package ssh (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
ssh
E: Sub-process /usr/bin/dpkg returned an error code (1)
以下是命令 sudo service ssh status
输出:
root@mqzhang:~# sudo service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Fri 2019-09-13 11:47:22 CEST; 5min ago
Process: 29933 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=1/FAILURE)
Process: 29929 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 29933 (code=exited, status=1/FAILURE)
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Main process exited, code=exited, status=1/FAILURE
Sep 13 11:47:22 mqzhang systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Unit entered failed state.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Failed with result 'exit-code'.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Service hold-off time over, scheduling restart.
Sep 13 11:47:22 mqzhang systemd[1]: Stopped OpenBSD Secure Shell server.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Start request repeated too quickly.
Sep 13 11:47:22 mqzhang systemd[1]: Failed to start OpenBSD Secure Shell server.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Unit entered failed state.
Sep 13 11:47:22 mqzhang systemd[1]: ssh.service: Failed with result 'start-limit-hit'.
我怎样才能解决这个问题?
答案1
首先删除 ssh
sudo apt-get remove openssh-server openssh-client --purge && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get update
然后重新安装
sudo apt-get install openssh-server openssh-client
来源:https://askubuntu.com/questions/603493/apt-get-dependency-issue-open-ssh-client