mirror of
https://github.com/romanz/amodem.git
synced 2026-03-27 05:19:04 +08:00
trezor: use identities instead of labels
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
@@ -10,12 +11,14 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
fmt = '%(asctime)s %(levelname)-12s %(message)-100s [%(filename)s]'
|
||||
fmt = '%(asctime)s %(levelname)-12s %(message)-100s [%(filename)s:%(lineno)d]'
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('-k', '--key-label',
|
||||
metavar='LABEL', dest='labels', action='append', default=[])
|
||||
p.add_argument('-v', '--verbose', action='count', default=0)
|
||||
p.add_argument('command', type=str, nargs='*')
|
||||
p.add_argument('-v', '--verbose', action='count', default=0,
|
||||
help='increase the the logging verbosity')
|
||||
p.add_argument('-c', dest='command', type=str, default=None,
|
||||
help='command to run under the SSH agent')
|
||||
p.add_argument('identity', type=str, nargs='*',
|
||||
help='proto://[user@]host[:port][/path]')
|
||||
args = p.parse_args()
|
||||
|
||||
verbosity = [logging.WARNING, logging.INFO, logging.DEBUG]
|
||||
@@ -24,20 +27,21 @@ def main():
|
||||
|
||||
with trezor.Client(factory=trezor.TrezorLibrary) as client:
|
||||
key_files = []
|
||||
for label in args.labels:
|
||||
pubkey = client.get_public_key(label=label)
|
||||
for label in args.identity:
|
||||
pubkey = client.get_public_key(label)
|
||||
key_file = formats.export_public_key(pubkey=pubkey, label=label)
|
||||
key_files.append(key_file)
|
||||
|
||||
if not args.command:
|
||||
sys.stdout.write(''.join(key_files))
|
||||
return
|
||||
command = args.command
|
||||
if not command:
|
||||
command = os.environ['SHELL']
|
||||
log.info('using %r shell', command)
|
||||
|
||||
signer = client.sign_ssh_challenge
|
||||
|
||||
try:
|
||||
with server.serve(key_files=key_files, signer=signer) as env:
|
||||
return server.run_process(command=args.command, environ=env)
|
||||
return server.run_process(command=command, environ=env)
|
||||
except KeyboardInterrupt:
|
||||
log.info('server stopped')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user