在 Debian 10“Buster”更新期间将 sshd 绑定到端口 2222 时出错

在 Debian 10“Buster”更新期间将 sshd 绑定到端口 2222 时出错

更新时出现以下错误输出:

Errors were encountered while processing: openssh-server ssh E: Sub-process /usr/bin/dpkg returned an error code (1) Setting up openssh-server (1:7.9p1-10+deb10u1) ... rescue-ssh.target is a disabled or a static unit, not starting it. 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; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-10-14 12:57:57 -03; 7ms ago Docs: man:sshd(8) man:sshd_config(5) Process: 22241 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Process: 22242 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=255/EXCEPTION) Main PID: 22242 (code=exited, status=255/EXCEPTION)

Oct 14 12:57:57 wdbuster systemd[1]: Starting OpenBSD Secure Shell server... Oct 14 12:57:57 wdbuster sshd[22242]: error: Bind to port 2222 on 0.0.0.0 failed: Address already in use. dpkg: error processing package openssh-server (--configure): installed openssh-server package post-installation script subprocess returned error exit status 1 dpkg: dependency problems prevent configuration of ssh: ssh depends on openssh-server (>= 1:7.9p1-10+deb10u1); 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 Press Return to continue, 'q' followed by Return to quit.

然后,$ sudo dpkg --audit返回以下输出:

The following packages have been unpacked but not yet configured. They must be configured using dpkg --configure or the configure menu option in dselect for them to work: ssh secure shell client and server (metapackage)

The following packages are only half configured, probably due to problems configuring them the first time. The configuration should be retried using dpkg --configure <package> or the configure menu option in dselect: openssh-server secure shell (SSH) server, for secure access from remote

还考虑到端口 22 更改为 2222,在/etc/ssh/sshd_config.

有任何想法吗?

答案1

可以按如下方式进行:

$ sudo systemctl disable sshd $ sudo systemctl daemon-reload $ sudo dpkg --configure openssh-server

然后,最后

$ systemctl enable sshd

相关内容