diff options
-rw-r--r-- | paramiko/client.py | 13 | ||||
-rw-r--r-- | paramiko/ed25519key.py | 12 |
2 files changed, 13 insertions, 12 deletions
diff --git a/paramiko/client.py b/paramiko/client.py index 42b52712..25bbffd9 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -594,14 +594,11 @@ class SSHClient (ClosingContextManager): (ECDSAKey, "ecdsa"), (Ed25519Key, "ed25519"), ]: - full_path = os.path.expanduser("~/.ssh/id_%s" % path) - if os.path.isfile(full_path): - keyfiles.append((keytype, full_path)) - - # look in ~/ssh/ for windows users: - full_path = os.path.expanduser("~/ssh/id_%s" % path) - if os.path.isfile(full_path): - keyfiles.append((keytype, full_path)) + # ~/ssh/ is for windows + for directory in [".ssh", "ssh"]: + full_path = os.path.expanduser("~/%s/id_%s" % (directory, path)) + if os.path.isfile(full_path): + keyfiles.append((keytype, full_path)) if not look_for_keys: keyfiles = [] diff --git a/paramiko/ed25519key.py b/paramiko/ed25519key.py index 694b1e15..e76a850e 100644 --- a/paramiko/ed25519key.py +++ b/paramiko/ed25519key.py @@ -25,6 +25,7 @@ import six from paramiko.message import Message from paramiko.pkey import PKey +from paramiko.ssh_exception import SSHException, PasswordRequiredException OPENSSH_AUTH_MAGIC = "openssh-key-v1\x00" @@ -78,12 +79,12 @@ class Ed25519Key(PKey): if kdfname == "none": # kdfname of "none" must have an empty kdfoptions, the ciphername - # must be "none" and there must not be a password. - if kdfoptions or ciphername != "none" or password: + # must be "none" + if kdfoptions or ciphername != "none": raise SSHException('Invalid key') elif kdfname == "bcrypt": if not password: - raise SSHException('Invalid key') + raise PasswordRequiredException('Private key file is encrypted') kdf = Message(kdfoptions) bcrypt_salt = kdf.get_binary() bcrypt_rounds = kdf.get_int() @@ -109,7 +110,10 @@ class Ed25519Key(PKey): password=password, salt=bcrypt_salt, desired_key_bytes=cipher['key-size'] + cipher['block-size'], - rounds=bcrypt_rounds + rounds=bcrypt_rounds, + # We can't control how many rounds are on disk, so no sense + # warning about it. + ignore_few_rounds=True, ) decryptor = Cipher( cipher['class'](key[:cipher['key-size']]), |