Skip to content

Commit

Permalink
Fix for already set SSH_ASKPASS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
ymage committed Aug 21, 2022
1 parent 4908899 commit e186367
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bw_add_sshkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def ssh_add(session: str, item_id: str, key_id: str, key_pw: Optional[str]) -> N
)
else:
envdict = dict(os.environ, SSH_ASKPASS_REQUIRE="never")

logging.debug("Running ssh-add")
# CAVEAT: `ssh-add` provides no useful output, even with maximum verbosity
subprocess.run(
Expand All @@ -236,7 +236,7 @@ def ssh_add(session: str, item_id: str, key_id: str, key_pw: Optional[str]) -> N
env=envdict,
universal_newlines=True,
check=True,
)
)


if __name__ == '__main__':
Expand Down Expand Up @@ -305,7 +305,7 @@ def main() -> None:
logging.error('"%s" error: %s', error.cmd[0], error.stderr)
logging.debug('Error running %s', error.cmd)

if os.environ.get('SSH_ASKPASS'):
if os.environ.get('SSH_ASKPASS') and os.environ.get('SSH_ASKPASS') == os.path.realpath(__file__):
print(os.environ.get('SSH_KEY_PASSPHRASE'))
else:
main()

0 comments on commit e186367

Please sign in to comment.