mirror of https://github.com/huashengdun/webssh
Merge a8f37c8d23
into 1cf19c7186
commit
e281d70051
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue