# Failed to restart sshd.service: unit network.service not found

**URL:** <https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201>\
**Category:** Rocky Linux Help & Support\
**Created:** [September 11, 2022, 10:42am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201 "2022-09-11T10:42:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob153](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rob153](https://forums.rockylinux.org/u/rob153)\
**Post date:** [September 11, 2022, 10:42am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/1 "2022-09-11T10:42:55Z")

</div>

After reboot (most recent updates?), I am no longer able to restart the sshd service:

`Failed to restart sshd.service: unit network.service not found`

Any ideas how to fix this? It seems that network.service is no longer there, but then why is sshd.service asking for it?

Any help greatly appreciated!

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [September 11, 2022, 3:11pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/2 "2022-09-11T15:11:16Z")

</div>

The sshd.service file should have:

```auto
After=network.target sshd-keygen.target

```

if yours says network.service then it is wrong - so either something has edited this sshd.service file, or someone else has edited it. And this is the same on both Rocky 8 and 9.

---

<div class="post-metadata">

**Author:** ![rob153](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rob153](https://forums.rockylinux.org/u/rob153)\
**Post date:** [September 11, 2022, 7:09pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/3 "2022-09-11T19:09:47Z")

</div>

The sshd.service file looks like you say it should. It requires network.target.  
But still, when I do  
`systemctl restart sshd`  
I get the error message  
`Failed to restart sshd.service: unit network.service not found`  
Any ideas where this could come from?

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [September 11, 2022, 7:20pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/4 "2022-09-11T19:20:24Z")

</div>

Can you do:

```auto
systemctl status network.target

```

and post the output?

---

<div class="post-metadata">

**Author:** ![rob153](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rob153](https://forums.rockylinux.org/u/rob153)\
**Post date:** [September 11, 2022, 7:25pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/5 "2022-09-11T19:25:35Z")

</div>

Looks normal:

```auto
● network.target - Network
   Loaded: loaded (/usr/lib/systemd/system/network.target; static; vendor preset: disabled)
   Active: active since Sun 2022-09-11 12:12:46 CEST; 9h ago
     Docs: man:systemd.special(7)
           https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget

Sep 11 12:12:46 localhost.localdomain systemd[1]: Reached target Network.

```

---

<div class="post-metadata">

**Author:** ![gerry666uk](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gerry666uk](https://forums.rockylinux.org/u/gerry666uk)\
**Post date:** [September 11, 2022, 9:51pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/6 "2022-09-11T21:51:40Z")

</div>

I think ‘network.service’ is related to using “legacy” network-scripts, which would not be normal on Rocky 8 or 9.

---

<div class="post-metadata">

**Author:** ![rob153](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rob153](https://forums.rockylinux.org/u/rob153)\
**Post date:** [September 11, 2022, 9:55pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/7 "2022-09-11T21:55:14Z")

</div>

Interesting. So are you saying it is something in my `/etc/sysconfig/network-scripts/*` that needs to be changed to fix this?

---

<div class="post-metadata">

**Author:** ![gerry666uk](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gerry666uk](https://forums.rockylinux.org/u/gerry666uk)\
**Post date:** [September 11, 2022, 10:46pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/8 "2022-09-11T22:46:09Z")

</div>

If it really is related to some legacy config, the first thing would be to think about how and why you’ve got a legacy config, e.g. do you have a pure new Rocky install using official repos, and everything using defaults? if so, this should not be happening.

---

<div class="post-metadata">

**Author:** ![rob153](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rob153](https://forums.rockylinux.org/u/rob153)\
**Post date:** [September 11, 2022, 10:51pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/9 "2022-09-11T22:51:18Z")

</div>

It is a pure new rocky install. And this used to work, it stopped working after a reboot for no apparent reason. I was assuming that it’s related to some update that happened recently, but I’m not sure. It’s the first reboot in a couple of months.

---

<div class="post-metadata">

**Author:** ![olista](https://avatars.discourse-cdn.com/v4/letter/o/7993a0/32.png) [@olista](https://forums.rockylinux.org/u/olista)\
**Post date:** [September 12, 2022, 3:54am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/10 "2022-09-12T03:54:35Z")

</div>

Can you please post the output of `systemctl status sshd.service` and the content of `/usr/lib/systemd/system/sshd.service` ?

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [September 12, 2022, 5:18am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/11 "2022-09-12T05:18:26Z")

</div>

> [@gerry666uk](#):
>
> I think ‘network.service’ is related to using “legacy” network-scripts, which would not be normal on Rocky 8 or 9.

If it’s this, it can be ruled out very quickly by:

```auto
dnf remove network-scripts

```

since this legacy package can be installed although shouldn’t be by default. This package doesn’t exist in Rocky 9 though.

That said network.service doesn’t exist in this package anyway, so shouldn’t be related to this. I would be more inclined to check for the existence of /usr/lib/systemd/system/sshd.service and check the entire content of this file, and perhaps also do:

```auto
find /etc/systemd -iname sshd.service

```

and check that the results shows a symlink to the /usr/lib/systemd/system/sshd.service file using `ls -l`, or whether it’s a copy of the sshd.service that may have been edited/played around with.

No packages from doing a dnf repoquery search shows as providing network.service so it sounds like an incorrectly formatted sshd.service file.

---

<div class="post-metadata">

**Author:** ![rob153](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rob153](https://forums.rockylinux.org/u/rob153)\
**Post date:** [September 12, 2022, 7:06am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/12 "2022-09-12T07:06:07Z")

</div>

Thanks very much for helping me investigate. You were right, there was an unusual modification.

Doing `grep -R "network\.service" /etc/systemd`, I found that there were additional config files under `/etc/systemd/system/sshd.service.d/` which had references to `network.service`.

I replaced these by `network.target` and now it works fine.

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [September 12, 2022, 8:09am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/13 "2022-09-12T08:09:32Z")

</div>

> [@rob153](#):
>
> additional config files under `/etc/systemd/system/sshd.service.d/`

Yes, that is the place where local customizations are put (for example, when you do `systemctl edit sshd.service` )

Systemctl does hint about that. Here is a service with default config:

```auto
# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2022-07-28 18:33:15 EEST; 1 months 15 days ago

```

And another, with customization by local admin:

```auto
# systemctl status krb5kdc.service
● krb5kdc.service - Kerberos 5 KDC
   Loaded: loaded (/usr/lib/systemd/system/krb5kdc.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/krb5kdc.service.d
           └─override.conf
   Active: active (running) since Thu 2022-07-28 18:33:27 EEST; 1 months 15 days ago

```

---

<div class="post-metadata">

**Author:** ![gerry666uk](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gerry666uk](https://forums.rockylinux.org/u/gerry666uk)\
**Post date:** [September 12, 2022, 6:49pm UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/14 "2022-09-12T18:49:41Z")

</div>

So the problem has been found, but it doesn’t really explain how the customized version got there in the first place.

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)\
**Post date:** [August 25, 2023, 3:40am UTC](https://forums.rockylinux.org/t/failed-to-restart-sshd-service-unit-network-service-not-found/7201/15 "2023-08-25T03:40:33Z")

</div>


