Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions blessclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,18 @@ def save_cached_creds(token_data, bless_config):
def ssh_agent_remove_bless(identity_file):
DEVNULL = open(os.devnull, 'w')
try:
current = subprocess.check_output(['ssh-add', '-l']).decode('UTF-8')
match = re.search(re.escape(identity_file), current)
if match:
subprocess.check_call(
['ssh-add', '-d', identity_file], stderr=DEVNULL)
subprocess.check_call(
['ssh-add', '-d', identity_file], stderr=DEVNULL)
except subprocess.CalledProcessError:
logging.debug(
"Non-zero exit from ssh-add, are there no identities in the current agent?")


def ssh_agent_add_bless(identity_file):
DEVNULL = open(os.devnull, 'w')
subprocess.check_call(['ssh-add', identity_file], stderr=DEVNULL)
current = subprocess.check_output(['ssh-add', '-l']).decode('UTF-8')
if not re.search(re.escape(identity_file), current):
try:
subprocess.check_call(['ssh-add', identity_file], stderr=DEVNULL)
except:
logging.debug("Could not add '{}' to ssh-agent".format(identity_file))
sys.stderr.write(
"Couldn't add identity to ssh-agent")
Expand Down