Advertisement
Guest User

Untitled

a guest
Aug 9th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import paramiko
  2.  
  3. # new instance of SSHClient
  4. ssh = paramiko.SSHClient()
  5.  
  6. # this will add host to list of know hosts
  7. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  8.  
  9. # create new connection to server
  10. # host string
  11. # username string
  12. # password string
  13. # host integer (default 22)
  14. ssh.connect('TU ZAJEBES ADDRESSU', username='TU MENO', password='A TU SVOJE 0000 CO MAS AKO HESLO')
  15.  
  16. # try to execute command
  17. # exec_command execute shell command on server site
  18. # return tuple with result of command
  19. try:
  20.     stdin, stdout, stderr = ssh.exec_command('ls -la /home/spamprison/')
  21. except Exception as e:
  22.     print('CATCHED EXCEPTION: ' + repr(e))
  23. finally:
  24.     # always close connection to server
  25.     ssh.close()
  26.     print('Connection closed ;)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement