1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

utils/ssh: Only try SSH keys if no password is supplied.

By default parmaiko attempts to search for SSH keys even when connecting
with a password. Ensure this is disabled to prevent issues where
non-valid keys are found on the host when connecting using password
authentication.
This commit is contained in:
Marc Bonnici 2020-03-11 10:32:03 +00:00
parent b6cab6467d
commit 779b0cbc77

View File

@ -350,6 +350,8 @@ class SshConnection(SshConnectionBase):
policy = RejectPolicy policy = RejectPolicy
else: else:
policy = AutoAddPolicy policy = AutoAddPolicy
# Only try using SSH keys if we're not using a password
check_ssh_keys = not self.password
with _handle_paramiko_exceptions(): with _handle_paramiko_exceptions():
client = SSHClient() client = SSHClient()
@ -362,6 +364,8 @@ class SshConnection(SshConnectionBase):
password=self.password, password=self.password,
key_filename=self.keyfile, key_filename=self.keyfile,
timeout=self.timeout, timeout=self.timeout,
look_for_keys=check_ssh_keys,
allow_agent=check_ssh_keys
) )
return client return client