Quantcast
Channel: SSH.NET Library
Viewing all articles
Browse latest Browse all 2955

Edited Issue: No Connection possible with the same auth method requested multiple times [1930]

$
0
0
If you try to connect to a server which requires more than one auth,
it only works it the auth-methods differ.

If you use:
```
AuthenticationMethods password,password
```
or
```
AuthenticationMethods pubkey,pubkey
```

it will fail with "no suitable auth methods..."

But this server config works with OpenSSH and Putty.

I nailed the issue down to Authenticate() in ConnectionInfo, where SSH.Net filters and counts auth-methods.
So a auth method can just used once!

Following quickpatch fixes the isse:

```
--- a/Renci.SshNet/ConnectionInfo.cs
+++ b/Renci.SshNet/ConnectionInfo.cs
@@ -411,7 +411,7 @@ public bool Authenticate(Session session)
while (authenticated != AuthenticationResult.Success)
{
// Find first authentication method
- var method = this.AuthenticationMethods.Where((a) => allowedAuthentications.Contains(a.Name) && !triedAuthentications.Contains(a.Name)).FirstOrDefault();
+ var method = this.AuthenticationMethods.Where((a) => allowedAuthentications.Contains(a.Name)).FirstOrDefault();
if (method == null)
throw new SshAuthenticationException("No suitable authentication method found to complete authentication.");

@@ -419,7 +419,7 @@ public bool Authenticate(Session session)

authenticated = method.Authenticate(session);

- if (authenticated == AuthenticationResult.PartialSuccess || (method.AllowedAuthentications != null && method.AllowedAuthentications.Count() < allowedAuthentications.Count()))
+ if (authenticated == AuthenticationResult.PartialSuccess || (method.AllowedAuthentications != null))
{
// If further authentication is required then continue to try another method
allowedAuthentications = method.AllowedAuthentications;
@@ -427,7 +427,7 @@ public bool Authenticate(Session session)
}

// If authentication Fail, and all the authentication have been tried.
- if (authenticated == AuthenticationResult.Failure && (triedAuthentications.Count() == allowedAuthentications.Count()))
+ if (authenticated == AuthenticationResult.Failure)
{
break;
}
```
Comments: ** Comment from web user: drieseng **

I've fixed this issue locally.
Once I've done some more tests, I'll commit the changes.
Thanks for the report!


Viewing all articles
Browse latest Browse all 2955

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>