481
482
if _try_pkey_auth(paramiko_transport, paramiko.DSSKey, username, 'id_dsa'):
485
# If we have gotten this far, we are about to try for passwords, do an
486
# auth_none check to see if it is even supported.
487
supported_auth_types = []
489
# Note that with paramiko <1.7.5 this logs an INFO message:
490
# Authentication type (none) not permitted.
491
# So we explicitly disable the logging level for this action
492
old_level = paramiko_transport.logger.level
493
paramiko_transport.logger.setLevel(logging.WARNING)
495
paramiko_transport.auth_none(username)
497
paramiko_transport.logger.setLevel(old_level)
498
except paramiko.BadAuthenticationType, e:
499
# Supported methods are in the exception
500
supported_auth_types = e.allowed_types
501
except paramiko.SSHException, e:
502
# Don't know what happened, but just ignore it
504
if 'password' not in supported_auth_types:
505
raise errors.ConnectionError('Unable to authenticate to SSH host as'
506
'\n %s@%s\nsupported auth types: %s'
507
% (username, host, supported_auth_types))
486
511
paramiko_transport.auth_password(username, password)
491
516
# give up and ask for a password
492
517
password = auth.get_password('ssh', host, username, port=port)
494
paramiko_transport.auth_password(username, password)
495
except paramiko.SSHException, e:
496
raise errors.ConnectionError(
497
'Unable to authenticate to SSH host as %s@%s' % (username, host), e)
518
# get_password can still return None, which means we should not prompt
519
if password is not None:
521
paramiko_transport.auth_password(username, password)
522
except paramiko.SSHException, e:
523
raise errors.ConnectionError(
524
'Unable to authenticate to SSH host as'
525
'\n %s@%s\n' % (username, host), e)
527
raise errors.ConnectionError('Unable to authenticate to SSH host as'
528
' %s@%s' % (username, host))
500
531
def _try_pkey_auth(paramiko_transport, pkey_class, username, filename):