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:
...@@ -142,6 +142,8 @@ class SFTPFS(FS): ...@@ -142,6 +142,8 @@ class SFTPFS(FS):
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)
...@@ -153,15 +155,20 @@ class SFTPFS(FS): ...@@ -153,15 +155,20 @@ class SFTPFS(FS):
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