Systemd: how to make a systemd service start after network fully connected?

When there is a question about a systemd directive, you can use man systemd.directives to find where it's documented. In this case it shows that After= is documented in man systemd.unit.

In that file, it shows that After= directive is listed in the "[UNIT] SECTION OPTIONS", indicating that it belongs in the [Unit] section of the file.

The same documentation also documents the [INSTALL] section options, and After= is not listed there.

In short, your After= directive was in the wrong location the unit file so it had no effect until you moved it to the correct location.


Have it fixed by modifying the service as

[Unit]
Description=Turn on LED after SSH is ready
After=network-online.target

[Service]
Type=idle
ExecStart=/usr/bin/sshready.py

[Install]
WantedBy=network-online.target

Still didn't fully understand what I was doing, but it works now. Can anyone please explain?

Update

This answer was created by myself before the accepted answer comes.