#!/usr/bin/env python3 import argparse import shlex import subprocess def run_process(process_name): """ Run the given process. """ return subprocess.run(shlex.split(process_name)) if __name__ == "__main__": parser = argparse.ArgumentParser( prog="ssh_server_control", description="Start, stop, or show the status of the SSH server.", ) _ = parser.add_argument( "--start", action="store_true", default=False, help="Start the SSH server" ) _ = parser.add_argument( "--stop", action="store_true", default=False, help="Stop the SSH server" ) _ = parser.add_argument( "--status", action="store_true", default=False, help="Show the status of the SSH server", ) args = parser.parse_args() if args.start: run_process("sudo systemctl start ssh") if args.stop: run_process("sudo systemctl stop ssh") if args.status: run_process("sudo systemctl status ssh")