Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/scmrepo/git/backend/dulwich/asyncssh_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ async def public_key_auth_requested( # pylint: disable=invalid-overridden-metho
self,
) -> Optional["KeyPairListArg"]:
from asyncssh.public_key import (
_DEFAULT_KEY_FILES,
KeyImportError,
SSHLocalKeyPair,
read_private_key,
Expand All @@ -169,12 +170,20 @@ async def public_key_auth_requested( # pylint: disable=invalid-overridden-metho
options = self._conn._options # pylint: disable=protected-access
config = options.config
client_keys = cast(Sequence["FilePath"], config.get("IdentityFile", ()))
if not client_keys:
client_keys = [
os.path.expanduser(os.path.join("~", ".ssh", path))
for path, cond in _DEFAULT_KEY_FILES
if cond
]
for key_to_load in client_keys:
try:
read_private_key(key_to_load, passphrase=options.passphrase)
except KeyImportError as exc:
if str(exc).startswith("Passphrase"):
self._keys_to_try.append(key_to_load)
except OSError:
pass

while self._keys_to_try:
key_to_load = self._keys_to_try.pop()
Expand Down