Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- # new instance of SSHClient
- ssh = paramiko.SSHClient()
- # this will add host to list of know hosts
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- # create new connection to server
- # host string
- # username string
- # password string
- # host integer (default 22)
- ssh.connect('TU ZAJEBES ADDRESSU', username='TU MENO', password='A TU SVOJE 0000 CO MAS AKO HESLO')
- # try to execute command
- # exec_command execute shell command on server site
- # return tuple with result of command
- try:
- stdin, stdout, stderr = ssh.exec_command('ls -la /home/spamprison/')
- except Exception as e:
- print('CATCHED EXCEPTION: ' + repr(e))
- finally:
- # always close connection to server
- ssh.close()
- print('Connection closed ;)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement