pull/144/merge
Michael Ramsey 2023-05-05 14:12:36 -07:00 committed by GitHub
commit e281d70051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -66,6 +66,21 @@ class SSHClient(paramiko.SSHClient):
allowed_types = set()
two_factor_types = {'keyboard-interactive', 'password'}
agent = paramiko.Agent()
agent_keys = agent.get_keys()
if len(agent_keys) == 0:
return
for key in agent_keys:
logging.info("Trying ssh-agent key %s" % hexlify(key.get_fingerprint()))
try:
self._transport.auth_publickey(username, key)
logging.info("... success!")
return
except paramiko.SSHException as e:
logging.info("... nope.")
saved_exception = e
if pkey is not None:
logging.info('Trying publickey authentication')
try:
@ -452,7 +467,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
logging.info('Connecting to {}:{}'.format(*dst_addr))
try:
ssh.connect(*args, timeout=options.timeout)
ssh.connect(*args, allow_agent=True, look_for_keys=True, timeout=options.timeout)
except socket.error:
raise ValueError('Unable to connect to {}:{}'.format(*dst_addr))
except paramiko.BadAuthenticationType: