From f5a7f80fd40f9765959f8a78754f24697d09a69e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 9 Oct 2020 16:38:19 -0500 Subject: [PATCH] More tweaks to logic for caching ssh host key --- rattail_fabric2/ssh.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rattail_fabric2/ssh.py b/rattail_fabric2/ssh.py index 2b27be0..6a88f48 100644 --- a/rattail_fabric2/ssh.py +++ b/rattail_fabric2/ssh.py @@ -49,16 +49,16 @@ def cache_host_key(c, host, port=None, user=None, **kwargs): # basic command failed, but in some cases that is simply b/c normal # commands are not allowed, although the ssh connection itself was # established okay. here we check for that situation. - if result.stderr.strip() != "Disallowed command": + if "Disallowed command" not in result.stderr: # okay then we now think that the ssh connection itself was not # made, which presumably means we *do* need to cache the host key, # so try that now cmd = 'ssh -o StrictHostKeyChecking=no {} {} whoami'.format(port, host) if user: - c.sudo(cmd, user=None if user == 'root' else user) + c.sudo(cmd, user=None if user == 'root' else user, warn=True) else: - c.run(cmd) + c.run(cmd, warn=True) def restart(c):