Advertisement
johnmahugu

python - paramiko remote SSH

Jul 12th, 2016
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1.  
  2. """
  3. You will need to ssh into the remote machine and if you have appropriate credentials, you can invoke the shell scripts.
  4. For using ssh, you can easily use paramiko module that provides ssh automation
  5.    http://www.lag.net/paramiko/
  6. A typical example:
  7. """
  8. import paramiko
  9. import sys
  10. import os
  11. import os.path
  12. passwd = ""
  13. ssh = paramiko.SSHClient()
  14. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  15. ssh.connect('servername', username, password=passwd)
  16. stdin, stdout, stderr = ssh.exec_command('df -h')
  17. x = stdout.readlines()
  18. print x
  19. for line in x:
  20.     print line
  21. ssh.close()
  22.  
  23. #Replace "df -h" command with the your shell script.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement