In case you have an old legacy system with Python 2 still in use and want to make a script to run certain commands in a client server network.
import subprocess def ssh_exec_command(hostname, username, private_key_path, command): ssh_cmd = ['ssh', '-i', private_key_path, '-o', 'StrictHostKeyChecking=no', f'{username}@{hostname}', command] ssh_process = subprocess.Popen( ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) output, error = ssh_process.communicate() if...
ing. M.A.C.M. (Martijn) van den BoomComputer Infrastructure Engineeringenieur, docent en mentor
