Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ssh = SSHConfig()
- params = ssh.lookup(user_password_rnm)
- ssh = SSHClient()
- ssh.set_missing_host_key_policy(AutoAddPolicy())
- ssh.connect(ipAddress_rnm, port=22, username=user_name_rnm,
- password=user_password_rnm)
- if ssh.invoke_shell():
- st = ['with: ', name_rnm, ' - OK']
- showinfo('Connection', ' '.join(st))
- ssh.close()
- else:
- st = ['with: ', name_rnm, ' - NO CONNECT']
- showinfo('Connection', ' '.join(st))
- try:
- ssh.connect(ipAddress_rnm, port=22, username=user_name_rnm, password=user_password_rnm)
- ssh.invoke_shell()
- st = 'with: {0} - OK'.format(name_rnm)
- showinfo('Connection', st)
- ssh.close()
- except (BadHostKeyException, AuthenticationException, SSHException) as e:
- st = 'with: {0} - NO CONNECT. Reason: {1}'.format(name_rnm, str(e))
- showinfo('Connection', st)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement