pull/144/merge
Michael Ramsey 2025-08-19 13:52:32 +08:00 committed by GitHub
commit 8b94123f45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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: