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: da_rinkes **
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: da_rinkes **
Just to be clear, the patch is not a real patch! It just gives a basic idea where the problem is.