From f3cd4a9e26ca2f8d5e07fdf647ee2413b914b608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Fourrier?= Date: Tue, 11 May 2021 10:13:04 +0200 Subject: [PATCH] Fix faulty condition checking --- bw_add_sshkeys.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bw_add_sshkeys.py b/bw_add_sshkeys.py index be2abe6..9cd96d6 100644 --- a/bw_add_sshkeys.py +++ b/bw_add_sshkeys.py @@ -153,7 +153,9 @@ def add_ssh_keys(session, items, keyname): continue logging.debug('Private key ID found') - if not ssh_add(session, item['id'], private_key_id): + try: + ssh_add(session, item['id'], private_key_id) + except subprocess.SubprocessError: logging.warning('Could not add key to the SSH agent') @@ -181,7 +183,7 @@ def ssh_add(session, item_id, key_id): logging.debug("Running ssh-add") # CAVEAT: `ssh-add` provides no useful output, even with maximum verbosity - proc_ssh_add = subprocess.run( + subprocess.run( ['ssh-add', '-'], input=ssh_key, text=True,