To make a script to run remote commands in a client server network.
import subprocess def ssh_exec_command(hostname, username, command): ssh_cmd = ['ssh', f'{username}@{hostname}', command] ssh_process = subprocess.Popen( ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) output, error = ssh_process.communicate() if error: print("Error:", error) else: print("Output:", output) # Replace these with your actual credentials and command...
ing. M.A.C.M. (Martijn) van den BoomComputer Infrastructure Engineeringenieur, docent en mentor
