Skip to content

Commit

Permalink
Add the ability to add additional identities via the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzier committed Jan 30, 2023
1 parent cd972ed commit 502e578
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libagent/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def create_agent_parser(device_type):

p.add_argument('identity', type=_to_unicode, default=None,
help='proto://[user@]host[:port][/path]')

p.add_argument('-i', '--additional_identities', type=_to_unicode, default=[], action='append',
help='proto://[user@]host[:port][/path]')

p.add_argument('command', type=str, nargs='*', metavar='ARGUMENT',
help='command to run under the SSH agent')
return p
Expand Down Expand Up @@ -250,12 +254,19 @@ def _get_sock_path(args):
return sock_path


def _add_additional_identities(identities, additional_identities, ecdsa_curve_name):
for identity in additional_identities:
identities.append(device.interface.Identity(
identity_str=identity, curve_name=ecdsa_curve_name))


@handle_connection_error
def main(device_type):
"""Run ssh-agent using given hardware client factory."""
args = create_agent_parser(device_type=device_type).parse_args()
util.setup_logging(verbosity=args.verbose, filename=args.log_file)

identities = []
public_keys = None
filename = None
if args.identity.startswith('/'):
Expand All @@ -268,6 +279,9 @@ def main(device_type):
else:
identities = [device.interface.Identity(
identity_str=args.identity, curve_name=args.ecdsa_curve_name)]

_add_additional_identities(identities, args.additional_identities, args.ecdsa_curve_name)

for index, identity in enumerate(identities):
identity.identity_dict['proto'] = 'ssh'
log.info('identity #%d: %s', index, identity.to_string())
Expand Down

0 comments on commit 502e578

Please sign in to comment.