SHARE
TWEET

Untitled

a guest May 22nd, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import paramiko
  2.  
  3. remote_machine_name = raw_input('Enter the remote machine name:')
  4.  
  5. ssh = paramiko.SSHClient()
  6. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  7. try:
  8.     ssh.connect(remote_machine_name, username='xxx', password='yyy')
  9.     print "connected successfully!"
  10.  
  11. except paramiko.SSHException:
  12.     print "connection error"
  13.    
  14. stdin, stdout, stderr = ssh.exec_command('(cd path;./shellscript.sh)')
  15.  
  16. print "stderr: ", stderr.readlines()
  17. print "stdout: ", stdout.readlines()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top