summaryrefslogtreecommitdiff
path: root/demos/demo_simple.py
diff options
context:
space:
mode:
authorSebastian Deiss <s.deiss@science-computing.de>2014-02-17 10:49:05 +0100
committerSebastian Deiss <s.deiss@science-computing.de>2014-02-17 10:49:05 +0100
commit604980e9dfeb671da27178c5261ae39dfb5e2f32 (patch)
tree14207250652229dda445316997ddb580290d8ed1 /demos/demo_simple.py
parent3e1f9f09b1da0397f82e4ee9e1886f5271705e29 (diff)
downloadparamiko-604980e9dfeb671da27178c5261ae39dfb5e2f32.tar.gz
Improved handling of failed GSS-API authentication attempts
Previously an attribute error occurred or a SSHException was thrown if the GSS-API authentication failed. If GSS-API authentication fails now or the remote host does not support GSS-API, paramiko tries other authentication methods.
Diffstat (limited to 'demos/demo_simple.py')
-rwxr-xr-xdemos/demo_simple.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/demos/demo_simple.py b/demos/demo_simple.py
index 100e15f5..a9d363da 100755
--- a/demos/demo_simple.py
+++ b/demos/demo_simple.py
@@ -64,7 +64,7 @@ if username == '':
username = input('Username [%s]: ' % default_username)
if len(username) == 0:
username = default_username
-if not UseGSSAPI:
+if not UseGSSAPI or (not UseGSSAPI and not DoGSSAPIKeyExchange):
password = getpass.getpass('Password for %s@%s: ' % (username, hostname))
@@ -74,13 +74,17 @@ try:
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
print('*** Connecting...')
- if not UseGSSAPI:
+ if not UseGSSAPI or (not UseGSSAPI and not DoGSSAPIKeyExchange):
client.connect(hostname, Port, username, password)
else:
# SSPI works only with the FQDN of the target host
hostname = socket.getfqdn(hostname)
- client.connect(hostname, Port, username, gss_auth=UseGSSAPI,
- gss_kex=DoGSSAPIKeyExchange)
+ try:
+ client.connect(hostname, Port, username, gss_auth=UseGSSAPI,
+ gss_kex=DoGSSAPIKeyExchange)
+ except Exception:
+ password = getpass.getpass('Password for %s@%s: ' % (username, hostname))
+ client.connect(hostname, Port, username, password)
chan = client.invoke_shell()
print(repr(client.get_transport()))
print('*** Here we go!\n')