Guest User

Untitled

a guest
Jan 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. self.client = paramiko.SSHClient()
  2. hostkey = self.ssh_hostkey.split(' ')
  3. self.client.get_host_keys().add(self.ip, hostkey[0], paramiko.RSAKey(data=base64.b64decode(hostkey[1])))
  4. privkey_file = io.StringIO()
  5. privkey_file.write(self.ssh_privkey)
  6. privkey_file.seek(0)
  7. privkey = paramiko.RSAKey.from_private_key(privkey_file)
  8. try:
  9. self.client.connect(
  10. hostname=self.ip,
  11. username='root',
  12. pkey=privkey,
  13. password=self.router_password, # will try private key first, then password
  14. allow_agent=False,
  15. look_for_keys=False,
  16. )
  17. self.last_connect = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime())
  18. print_msg(1, "Connected to {}".format(self.nickname))
  19. except paramiko.ssh_exception.AuthenticationException:
  20. self.client = None
Add Comment
Please, Sign In to add comment