Advertisement
Guest User

Untitled

a guest
May 19th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import paramiko
  2.  
  3.  
  4. def ssh_command(hostname, port, username, password, command):
  5.  
  6.     ssh_client = paramiko.SSHClient()
  7.     ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  8.     ssh_client.load_system_host_keys()
  9.     ssh_client.connect(hostname, port, username, password)
  10.  
  11.     stdin, stdout, stderr = ssh_client.exec_command(command)
  12.     print(stdout.read().decode('UTF-8'))
  13.  
  14.  
  15. if __name__ == '__main__':
  16.     hostname = input("Hostname: ")
  17.     username = input("Username: ")
  18.     password = input("Passowrd: ")
  19.     port = input("Port: ")
  20.     command = input("Command TODO: ")
  21.     ssh_command(hostname, port, username, password, command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement