""" AUTHOR: Khushal P Soonderji DATE: Saturday, 15th Feb., 2025. OBJECTIVE: ??? REFERENCES: N/A DOWNLOADS: N/A """ # ***************************************************************************************************************** # ***** **** # *** IMPORT *** # ***** **** # ***************************************************************************************************************** # To make sibling directories accessible for imports: import sys sys.path.append(".") sys.path.append("..") # System-level activities: import io import os # For SSH: from paramiko import SSHClient, AutoAddPolicy # ***************************************************************************************************************** # ***** **** # *** MACROS / ONE-TIME INIT *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** VARIABLES *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** FUNCTIONS *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** MAIN PROGRAM *** # ***** **** # ***************************************************************************************************************** if __name__ == "__main__": ssh_client = SSHClient() # ssh_client.load_host_keys("~/.ssh/known_hosts") ssh_client.load_system_host_keys() ssh_client.set_missing_host_key_policy(AutoAddPolicy()) ssh_client.connect( hostname = "x.x.x.x", username = "user", password = "pass" ) std_in, std_out, std_err = ssh_client.exec_command("hostname") print("IN :", std_in.read().decode("utf8")) print("OUT:", std_out.read().decode("utf8")) print("ERR:", std_err.read().decode("utf8")) print("RET. CODE:", std_out.channel.recv_exit_status()) std_in.close() std_out.close() std_err.close() ssh_client.close()