diff --git a/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs b/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs index 508c4582..8d99b03f 100644 --- a/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs +++ b/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs @@ -373,10 +373,12 @@ namespace Renci.SshNet var allowedAuthentications = noneAuthenticationMethod.AllowedAuthentications; + var triedAuthentications = new List(); while (authenticated != AuthenticationResult.Success) { // Find first authentication method - var method = this.AuthenticationMethods.Where((a) => allowedAuthentications.Contains(a.Name)).FirstOrDefault(); + var method = this.AuthenticationMethods.Where((a) => allowedAuthentications.Contains(a.Name) && !triedAuthentications.Contains(a.Name)).FirstOrDefault(); + triedAuthentications.Add(method.Name); if (method == null) throw new SshAuthenticationException("No suitable authentication method found to complete authentication.");