简体   繁体   中英

How do you handle errors raised in Python Paramiko?

self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
    self.ssh.connect(self.hostname, username=self.username, password=self.password)
except SSHException:
    #do something

I was wondering how to handle errors raised by Paramiko when trying to connect to an SSH server?

Depends on your application.

Here are some possible actions:

  • Terminate
  • Retry
  • Log the error and continue doing something else

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM