Commit b6c21954 by willmcgugan

sftpfs authentication tweaks

parent c5d09ac3
...@@ -133,7 +133,7 @@ class SFTPFS(FS): ...@@ -133,7 +133,7 @@ class SFTPFS(FS):
connection.start_client() connection.start_client()
if not connection.is_active(): if not connection.is_active():
raise RemoteConnectionError('Unable to connect') raise RemoteConnectionError(msg='Unable to connect')
if no_auth: if no_auth:
try: try:
...@@ -141,27 +141,34 @@ class SFTPFS(FS): ...@@ -141,27 +141,34 @@ class SFTPFS(FS):
except paramiko.SSHException: except paramiko.SSHException:
pass pass
if not connection.is_authenticated(): if not connection.is_authenticated():
if not username:
username = getuser()
try: try:
if pkey: if pkey:
connection.auth_publickey(username, pkey) connection.auth_publickey(username, pkey)
if not connection.is_authenticated() and password: if not connection.is_authenticated() and password:
connection.auth_password(username, password) connection.auth_password(username, password)
if agent_auth and not connection.is_authenticated(): if agent_auth and not connection.is_authenticated():
self._agent_auth(connection, username) self._agent_auth(connection, username)
if not connection.is_authenticated(): if not connection.is_authenticated():
connection.auth_none('') try:
connection.auth_none(username)
except paramiko.BadAuthenticationType, e:
connection.close()
allowed = ', '.join(e.allowed_types)
raise RemoteConnectionError(msg='no auth - server requires one of the following: %s' % allowed, details=e)
if not connection.is_authenticated(): if not connection.is_authenticated():
connection.close() connection.close()
raise RemoteConnectionError('no auth') raise RemoteConnectionError(msg='no auth')
except paramiko.SSHException, e: except paramiko.SSHException, e:
connection.close() connection.close()
raise RemoteConnectionError('SSH exception (%s)' % str(e), details=e) raise RemoteConnectionError(msg='SSH exception (%s)' % str(e), details=e)
self._transport = connection self._transport = connection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment