From 779b0cbc7748adef15a1039ec5c4c6ad5295c8dd Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Wed, 11 Mar 2020 10:32:03 +0000 Subject: [PATCH] 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. --- devlib/utils/ssh.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index b871e22..6ecd131 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -350,6 +350,8 @@ class SshConnection(SshConnectionBase): policy = RejectPolicy else: policy = AutoAddPolicy + # Only try using SSH keys if we're not using a password + check_ssh_keys = not self.password with _handle_paramiko_exceptions(): client = SSHClient() @@ -362,6 +364,8 @@ class SshConnection(SshConnectionBase): password=self.password, key_filename=self.keyfile, timeout=self.timeout, + look_for_keys=check_ssh_keys, + allow_agent=check_ssh_keys ) return client