If this fails:
ssh = paramiko.SSHClient()
ssh.connect( host, username = USER , pkey = MY_KEY, timeout = 2)
I get a traceback like:
File "<stdin>", line 1, in <module>
File "<stdin>", line 7, in bs_process
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 282, in connect
for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
I cant figure what kind/kinds of errors Paramiko throws for bad connect attempts. Which are the exception classes and how can I import them?
You can start by looking at the API documentation, for all classes ending in Exception:
http://docs.paramiko.org/en/1.15/api/client.html#paramiko.client.SSHClient.connect
Then, you should also catch socket.error
. I think that will get you pretty much everything. socket.gaierror
is a subclass of socket.error
, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With