Updated: 28 September 2026 · Applies to: systemd 252 to 259 on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13
systemctl can manage services on another server directly, over SSH, without logging in to it first. This is handy when you look after several servers: check a service, restart it or list failures from your own machine.
Before you start
- Both machines run systemd, and you can log in to the remote server with SSH. Key-based login is best, so no password prompts get in the way.
- Controlling services needs root on the remote side, so connect as
rootor as a user with the right permissions.
Use -H (--host)
systemctl -H root@203.0.113.10 status nginx systemctl -H root@203.0.113.10 restart nginx systemctl -H root@203.0.113.10 --failed systemctl -H root@203.0.113.10 list-units --type=service --state=running
If SSH listens on another port, add it after a colon: -H root@203.0.113.10:2222. Put IPv6 addresses in brackets. The command runs on the remote server and prints the result locally.
The simple alternative: ssh with a command
ssh root@203.0.113.10 'systemctl restart nginx && systemctl is-active nginx' ssh root@203.0.113.10 'journalctl -u nginx -n 30 --no-pager'
This works for any command, including journalctl for the service's logs.
Many servers at once
A short loop checks the same service everywhere:
for h in web1 web2 db1; do echo "$h: $(ssh root@$h systemctl is-active nginx)" done
For regular work across many servers, a configuration tool such as Ansible is the better choice, for example ansible webservers -b -m ansible.builtin.systemd -a "name=nginx state=restarted".
Common problems
- "Failed to connect to bus" or the command hangs: SSH login failed. Test with
ssh root@203.0.113.10 truefirst, and set up SSH keys. - "Access denied": the remote user has no right to control services. Connect as root, or use
ssh user@host sudo systemctl .... - A different port or key: put them in
~/.ssh/configunder a host alias;systemctl -Huses that file too.
Official documentation: systemctl (option --host).
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
