Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Connecting with Password AND Private Key File using SftpClient

$
0
0
I just tried it with following line in my sshd_config:
AuthenticationMethods password,password
So I have to enter the password twice. Which is totally valid.

Works fine with Putty or openssh, but fails with SSH.Net.
SSH.Net tries to be clever and counts/filters allowed auths vs. tried auths.
Which why it ignores the PartialSuccess-Message of the first password attempt.

following diffs fixes this:
--- 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;
                 }
I will open an issue.

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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