From be7e73db16cb3c9135d2939164527df5b4580e0d Mon Sep 17 00:00:00 2001 From: Metin Kaya Date: Mon, 15 Jan 2024 16:51:00 +0000 Subject: [PATCH] utils/ssh: Load host keys only if strict_host_check is true Loading host keys breaks setting up SSH connection (paramiko throws BadHostKeyException exception) if issuer does not want/need strict key matching. One use case for ignoring strict_host_check is automating virtual guests (i.e., over QEMU). Issuer may want to skip loading host keys and start with a blank list of known host keys for sure. Signed-off-by: Metin Kaya --- devlib/utils/ssh.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index d05bb25..4e1d82e 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -397,7 +397,8 @@ class SshConnection(SshConnectionBase): with _handle_paramiko_exceptions(): client = SSHClient() - client.load_system_host_keys() + if self.strict_host_check: + client.load_system_host_keys() client.set_missing_host_key_policy(policy) client.connect( hostname=self.host,