Systemd system and services manager can be controlled using the systemctl command line utility. It enables you to manage systemd locally or on a remote Linux machine over the SSH protocol.
In this short article, we will show you how to manage systemd system and service manager on a remote Linux machine over a SSH session.
Attention: We recommend using public/private key pairs for passwordless authentication for SSH, as opposed to passwords, and also employing additional methods to secure SSH service, as explained in these guides.
- SSH Passwordless Login Using SSH Keygen in 5 Easy Steps
- 5 Best Practices to Secure and Protect SSH Server
- How to Block SSH and FTP Access to Specific IP and Network Range
To connect to a remote server, run systemctl with the
-H flag as follows. In the command below, we are connecting to the remote server as the root user and status is a subcommand of systemctl utility used to view the status of the httpd service on centos.temint.lan (remote Linux server).
$ systemctl --host [email protected] status httpd.service OR $ systemctl -H [email protected] status httpd.service
Manage Systemd Service on Remote Linux
Similarly, you can also start, stop or restart remote systemd service as shown.
$ systemctl --host [email protected] start httpd.service $ systemctl --host [email protected] stop httpd.service $ systemctl --host [email protected] restart httpd.service
To end the session, simply type
[Ctrl+C]. For more information and usage options, see the systemctl man page:
$ man systemctl
That’s all for now! What follows is an assortment of systemd articles which you’ll find useful:
- The Story Behind: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linux
- Managing System Startup Process and Services (SysVinit, Systemd and Upstart)
- Manage Log Messages Under Systemd Using Journalctl [Comprehensive Guide]
- How to Create and Run New Service Units in Systemd Using Shell Script
- How to Change Runlevels (targets) in SystemD
In this article, we showed you how to manage systemd system and service manager on a remote Linux machine. Use the feedback section to ask questions or share your thoughts about this guide.