no suitable authentication method
Hi, I'm just getting started with SSH.NET. For my first test, I am trying to SSH into a Mac using username and password using PasswordAuthenticationMethod
// Setup Credentials and Server Information
var connectionInfo = new ConnectionInfo(Host, Username,
new AuthenticationMethod[] {
// Pasword based Authentication
new PasswordAuthenticationMethod(Username,Password),
// Key Based Authentication (using keys in OpenSSH Format)
//new PrivateKeyAuthenticationMethod(Username,
// new PrivateKeyFile[] {
// new PrivateKeyFile(PrivateKeyPath,PrivateKeyPassphrase)
// })
});
// Execute a (SHELL) Command - prepare upload directory
using (var sshclient = new SshClient(connectionInfo))
{
sshclient.Connect();
using (var cmd = sshclient.CreateCommand("mkdir -p /tmp/uploadtest && chmod +rw /tmp/uploadtest"))
{
cmd.Execute();
Console.WriteLine("Command>" + cmd.CommandText);
Console.WriteLine("Return Value = {0}", cmd.ExitStatus);
}
sshclient.Disconnect();
}
However, when I get to sshclient.Connect(), I get
Renci.SshNet.Common.SshAuthenticationException was unhandled
HResult=-2146233088
Message=No suitable authentication method found to complete authentication (publickey,keyboard-interactive).
Source=Renci.SshNet
StackTrace:
at Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session)
at Renci.SshNet.ConnectionInfo.Authenticate(ISession session, IServiceFactory serviceFactory)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at Apricot.Services.MacBuilder.Build() in D:\Loqu8\Apricot\apricot.server\src\Apricot.Services\RemoteBuilder.cs:line 45
at Apricot.Server.Console.Program.Main(String[] args) in D:\Loqu8\Apricot\apricot.server\src\Apricot.Server.Console\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Is there some setting I need to check to not be keyboard-interactive? Or only ssh key will work?
We are continuously experiencing the same error for a single user credential of a sftp server hosted in windows azure. Other users can be connected successfully with password authentication mode. Following is the code:
using (SftpClient _sftp = new SftpClient(_host, _username, _password)) { foreach (var d in _sftp.ConnectionInfo.Encryptions.Where(p => p.Key != "aes128-cbc").ToList()) { _sftp.ConnectionInfo.Encryptions.Remove(d.Key); }
try
{
_sftp.Connect();
} catch { //exception occurs.. } }
//exception details:
Error while connecting : Renci.SshNet.Common.SshAuthenticationException: No suitable authentication method found to complete authentication. at Renci.SshNet.ConnectionInfo.Authenticate(Session session) at Renci.SshNet.Session.Connect() at Renci.SshNet.BaseClient.Connect()
Any help from Renci team will be appreciated. It's really critical issue with our client.
@hrid Are you sure the credentials are valid? You also appear to be using an old version of SSH.NET. Please try using a more recent version.
Hey Gert,
Thanks for your quick response. I am sure about the credentials but how come the same Renci SSH.NET version works well with other credentials across sftp servers is what baffling us. I will try with the latest version going though but that's not our first choice.
Do you think it has something to do with the sftp user authentication mode settings?
Any help from you in this regard will help us.
Best Regards, Hridballav Saha Senior Software Engineer Finomial Technologies Pvt. Ltd.
From: Gert Driesen [email protected] Sent: 22 December 2016 01:22:57 To: sshnet/SSH.NET Cc: Hridballav Saha; Mention Subject: Re: [sshnet/SSH.NET] no suitable authentication method (#91)
@hridhttps://github.com/hrid Are you sure the credentials are valid? You also appear to be using an old version of SSH.NET. Please try using a more recent version.
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/sshnet/SSH.NET/issues/91#issuecomment-268622471, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKr9r4pKJ69kIi8eeVtQ9J-ppM61adhdks5rKYOZgaJpZM4KFF3-.
This issue was closed - why? I am experiencing this as well - winscp works with the same credentials.
The sample code in https://stackoverflow.com/a/39163024/90287 worked for me.