Skip to content

Commit 279231f

Browse files
Handle failure when a bad passphrase is paired with an encrypted key
1 parent e2a2fd5 commit 279231f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Products/DataCollector/SshClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
transport,
2828
userauth,
2929
)
30-
from twisted.conch.ssh.keys import Key
30+
from twisted.conch.ssh.keys import BadKeyError, Key
3131
from twisted.internet import defer, reactor
3232
from zope.component import queryUtility
3333
from Products.ZenCollector.interfaces import IEventService
@@ -390,7 +390,7 @@ def _getKey(self):
390390
try:
391391
data = "".join(open(keyPath).readlines()).strip()
392392
key = Key.fromString(data, passphrase=self.factory.password)
393-
except IOError as ex:
393+
except (BadKeyError, IOError) as ex:
394394
message = "Unable to read the SSH key file because %s" % ex
395395
log.warn(message)
396396
device = "localhost" # Fallback

0 commit comments

Comments
 (0)