最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

Ubuntu20.04-解决Failedtoenableunit:Unitfilesshd。。。

IT圈 admin 44浏览 0评论

2023年12月7日发(作者:车睿聪)

Ubuntu20.04-解决Failedtoenableunit:Unitfilesshd。。。

文章目录

Ubuntu 版本信息:

$ lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 20.04.3 LTS

Release: 20.04

Codename: focal

起因

事情是这样的,原本 SSH 服务是可用的:

$ sudo systemctl status sshd

[sudo] password for mk:

● e - OpenBSD Secure Shell server

Loaded: loaded (/lib/systemd/system/e; enabled; vendor preset: enabled)

Active: active (running) since Sat 2022-02-19 19:19:56 CST; 1min 23s ago

Docs: man:sshd(8)

man:sshd_config(5)

Process: 840 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)

Main PID: 856 (sshd)

Tasks: 1 (limit: 4588)

Memory: 2.4M

CGroup: //e

└─856 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

2月 19 19:19:56 mk-virtual-machine systemd[1]: Starting OpenBSD Secure

2月 19 19:19:56 mk-virtual-machine sshd[856]: Server listening on 0.0.0.0 port 22.

2月 19 19:19:56 mk-virtual-machine sshd[856]: Server listening on :: port 22.

2月 19 19:19:56 mk-virtual-machine systemd[1]: Started OpenBSD Secure Shell server.

嗯,我手痒,执行了

sudo systemctl disable sshd

命令:

$ sudo systemctl disable sshd

Removed /etc/systemd/system/e.

Removed /etc/systemd/system//e.

当我再次使用

sudo systemctl status sshd

命令,就出现了:

$ sudo systemctl status sshd

Unit e could not be found.

使用

sudo systemctl enable sshd

sudo systemctl restart sshd

命令,也出现类似情况:

$ sudo systemctl enable sshd

Failed to enable unit: Unit file e does not exist.

$ sudo systemctl restart sshd

Failed to restart e: Unit e not found.

解决方法

后来是卸载、重装 SSH 才得以解决:

$ sudo apt-get remove --purge openssh-server

$ sudo apt-get update

$ sudo apt-get install openssh-server参考

2023年12月7日发(作者:车睿聪)

Ubuntu20.04-解决Failedtoenableunit:Unitfilesshd。。。

文章目录

Ubuntu 版本信息:

$ lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 20.04.3 LTS

Release: 20.04

Codename: focal

起因

事情是这样的,原本 SSH 服务是可用的:

$ sudo systemctl status sshd

[sudo] password for mk:

● e - OpenBSD Secure Shell server

Loaded: loaded (/lib/systemd/system/e; enabled; vendor preset: enabled)

Active: active (running) since Sat 2022-02-19 19:19:56 CST; 1min 23s ago

Docs: man:sshd(8)

man:sshd_config(5)

Process: 840 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)

Main PID: 856 (sshd)

Tasks: 1 (limit: 4588)

Memory: 2.4M

CGroup: //e

└─856 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

2月 19 19:19:56 mk-virtual-machine systemd[1]: Starting OpenBSD Secure

2月 19 19:19:56 mk-virtual-machine sshd[856]: Server listening on 0.0.0.0 port 22.

2月 19 19:19:56 mk-virtual-machine sshd[856]: Server listening on :: port 22.

2月 19 19:19:56 mk-virtual-machine systemd[1]: Started OpenBSD Secure Shell server.

嗯,我手痒,执行了

sudo systemctl disable sshd

命令:

$ sudo systemctl disable sshd

Removed /etc/systemd/system/e.

Removed /etc/systemd/system//e.

当我再次使用

sudo systemctl status sshd

命令,就出现了:

$ sudo systemctl status sshd

Unit e could not be found.

使用

sudo systemctl enable sshd

sudo systemctl restart sshd

命令,也出现类似情况:

$ sudo systemctl enable sshd

Failed to enable unit: Unit file e does not exist.

$ sudo systemctl restart sshd

Failed to restart e: Unit e not found.

解决方法

后来是卸载、重装 SSH 才得以解决:

$ sudo apt-get remove --purge openssh-server

$ sudo apt-get update

$ sudo apt-get install openssh-server参考

发布评论

评论列表 (0)

  1. 暂无评论