Merge pull request #83 from MineRobber9000/patch-1

Need a passphrase to decrypt, not password
pull/104/head
Shengdun Hua 2019-09-07 07:33:58 +08:00 committed by GitHub
commit 8d0567329f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -152,12 +152,12 @@ class TestPrivateKey(unittest.TestCase):
pk = self.get_pk_obj(fname, password='')
with self.assertRaises(InvalidValueError) as ctx:
pk.get_pkey_obj()
self.assertIn('Need a password', str(ctx.exception))
self.assertIn('Need a passphrase', str(ctx.exception))
pk = self.get_pk_obj(fname, password='wrongpass')
with self.assertRaises(InvalidValueError) as ctx:
pk.get_pkey_obj()
self.assertIn('wrong password', str(ctx.exception))
self.assertIn('wrong passphrase', str(ctx.exception))
pk = self.get_pk_obj(fname, password=password)
self.assertIsInstance(pk.get_pkey_obj(), klass)

View File

@ -153,12 +153,12 @@ class PrivateKey(object):
try:
return pkeycls.from_private_key(self.iostr, password=password)
except paramiko.PasswordRequiredException:
raise InvalidValueError('Need a password to decrypt the key.')
raise InvalidValueError('Need a passphrase to decrypt the key.')
except paramiko.SSHException as exc:
logging.error(str(exc))
msg = 'Invalid key'
if self.password:
msg += ' or wrong password "{}" for decrypting it.'.format(
msg += ' or wrong passphrase "{}" for decrypting it.'.format(
self.password)
raise InvalidValueError(msg)