Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- self.client = paramiko.SSHClient()
- hostkey = self.ssh_hostkey.split(' ')
- self.client.get_host_keys().add(self.ip, hostkey[0], paramiko.RSAKey(data=base64.b64decode(hostkey[1])))
- privkey_file = io.StringIO()
- privkey_file.write(self.ssh_privkey)
- privkey_file.seek(0)
- privkey = paramiko.RSAKey.from_private_key(privkey_file)
- try:
- self.client.connect(
- hostname=self.ip,
- username='root',
- pkey=privkey,
- password=self.router_password, # will try private key first, then password
- allow_agent=False,
- look_for_keys=False,
- )
- self.last_connect = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime())
- print_msg(1, "Connected to {}".format(self.nickname))
- except paramiko.ssh_exception.AuthenticationException:
- self.client = None
Add Comment
Please, Sign In to add comment