Remix.run Logo
mindcrime 7 hours ago

It wasn't literally today, but about 2 days ago I discovered the -H (and --host) arguments to systemctl. These allow you to pass a hostname of a remote server, so you can use systemctl to manage systemd services on remote machines. It layers over ssh, so the cleanest way to do it is to have passwordless ssh with certificates set up to the remote host. If you do, running systemctl commands remotely is totally seamless.

https://www.tecmint.com/control-systemd-services-on-remote-l...

yjftsjthsd-h 4 hours ago | parent [-]

What's the advantage to

  systemctl --host foo status httpd.service
vs

  ssh -t foo systemctl status httpd.service

?
mindcrime an hour ago | parent | next [-]

> What's the advantage to ...

For me personally, I'd say "not much". I'm used to using the latter form, and it's fine. But I will say that now that I know about this, I see using it in scenarios where I'm running a lot of systemctl commands over and over again in close proximity and have the "muscle memory" of typing "systemctl" more in mind.

For example, when working with a new service that isn't quite working right yet, and doing many iterations of:

    $> systemctl start something.service
    $> systemctl status something.service
    $> journalctl -xeu something.service
    $> emacs whatever
    $> systemctl start something.service
    $> systemctl status something.service
    lather, rinse, repeat
Especially if I'm testing on my laptop AND a remote deployment, I think it's easier from a cognitive viewpoint to always "think systemctl" instead of having to "think systemctl" sometimes and "think ssh systemctl" in others.

To be fair though, it's all a pretty minor point. But I do think it's cool that systemctl has that option. shrug

Aachen 2 hours ago | parent | prev [-]

Was wondering the same. "Do one thing and do it well" philosophy...

If I want to run remote commands, I know how to do that already (namely, as you've shown), why learn to use a new tool for it? It's like these options to tar for compression: if I want to have a gzipped tar I'll run the tar c /sdcard output through |gzip thank you very much! (and drop in zstd instead)