Guest User

Untitled

a guest
Jul 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. # might want an 'ignore' policy that doesn't chirp to stderr later
  2. client.set_missing_host_key_policy(paramiko.WarningPolicy())
  3.  
  4. key_obj = PrivateKey(self.key)
  5. self.key = None
  6. try:
  7. self.key = paramiko.DSSKey.from_private_key(file_obj=key_obj, password=self.password)
  8. except paramiko.SSHException:
  9. self.key = paramiko.RSAKey.from_private_key(file_obj=key_obj, password=self.password)
  10.  
  11. # try the ssh key, password protected keys are ok
  12. try:
  13. client.connect(
  14. self.host,
  15. port=self.port,
  16. username=self.user,
  17. password=self.password,
  18. look_for_keys=False,
  19. pkey=self.key,
  20. allow_agent=False
  21. )
Add Comment
Please, Sign In to add comment