Skip to content

Commit 502e578

Browse files
committed
Add the ability to add additional identities via the command line
1 parent cd972ed commit 502e578

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libagent/ssh/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def create_agent_parser(device_type):
114114

115115
p.add_argument('identity', type=_to_unicode, default=None,
116116
help='proto://[user@]host[:port][/path]')
117+
118+
p.add_argument('-i', '--additional_identities', type=_to_unicode, default=[], action='append',
119+
help='proto://[user@]host[:port][/path]')
120+
117121
p.add_argument('command', type=str, nargs='*', metavar='ARGUMENT',
118122
help='command to run under the SSH agent')
119123
return p
@@ -250,12 +254,19 @@ def _get_sock_path(args):
250254
return sock_path
251255

252256

257+
def _add_additional_identities(identities, additional_identities, ecdsa_curve_name):
258+
for identity in additional_identities:
259+
identities.append(device.interface.Identity(
260+
identity_str=identity, curve_name=ecdsa_curve_name))
261+
262+
253263
@handle_connection_error
254264
def main(device_type):
255265
"""Run ssh-agent using given hardware client factory."""
256266
args = create_agent_parser(device_type=device_type).parse_args()
257267
util.setup_logging(verbosity=args.verbose, filename=args.log_file)
258268

269+
identities = []
259270
public_keys = None
260271
filename = None
261272
if args.identity.startswith('/'):
@@ -268,6 +279,9 @@ def main(device_type):
268279
else:
269280
identities = [device.interface.Identity(
270281
identity_str=args.identity, curve_name=args.ecdsa_curve_name)]
282+
283+
_add_additional_identities(identities, args.additional_identities, args.ecdsa_curve_name)
284+
271285
for index, identity in enumerate(identities):
272286
identity.identity_dict['proto'] = 'ssh'
273287
log.info('identity #%d: %s', index, identity.to_string())

0 commit comments

Comments
 (0)