Given that ~/.ssh/config (and assumedly no /root/.ssh/config interfering again) it really should work to do
sudo ssh -v -i /home/majik/.ssh/Linksys_id_ed25519 192.168.1.1
Does this not give you a normal login as “root” on your router? If it doesn’t the “-v” again supposedly says why not. If it does, then
ExecStart=/usr/bin/ssh -v -i /home/majik/.ssh/Linksys_id_ed25519 192.168.1.1 poweroff
should work just as well from the systemd unit – assuming of course that your /home/majik/.ssh is not on some at the time of its execution already unmounted filesystem, i.e., assuming you haven’t split off your /home. I’ve left in the “-v” in the above so you can after booting up again check what’s up with
journalctl -b-1 -xu shutdown-router.service
It is assumed that you’ve placed your service file in /etc/systemd/system/shutdown-router.service and have used
systemctl enable shutdown-router.service
to enable it. You’d of course remove the “-v” once things work.
As to your direct question, and if the above isn’t yet helping: your service file as is pulls in poweroff.target, i.e., shuts down, so if you want to test “live” you need to comment that out:
#Requires=poweroff.target
You can then run it immediately as
systemctl start shutdown-router.service
and in case of failure again look at things with
journalctl -xu shutdown-router.service
FWIW I grabbed your service file from above and things just work here:
$ cat /etc/systemd/system/shutdown-router.service
[Unit]
Description=Shutdown router on system shutdown
DefaultDependencies=no
Before=poweroff.target halt.target shutdown.target
Requires=poweroff.target
[Service]
Type=oneshot
ExecStart=/usr/bin/ssh -v -i /home/rene/.ssh/id_rsa rene@hp8k poweroff
RemainAfterExit=yes
[Install]
WantedBy=shutdown.target
I’m logging in as “rene@” whereas you want “root@” or simply nothing but I don’t see why things would be different for you given that things work from the command line as your user as you stated – again at the time of shutdown modulo a potentially already unmounted /home.
[EDIT] Oh, let me by the way add that if you do have a split-off /home you may want to copy that key file to /root/.ssh/ and refer to it there with the “-i” parameter, or also duplicate the shown ~/.ssh/config in /root/.ssh/