On SshClient.Connect paramater "data" is null error

Jan 17, 2012 at 7:45 PM

I am using a windows form and just started testing out Sshnet.  I am using the Renci.SshNet.dll.  Im using the code below

using Renci.SshNet;
using Renci.SshNet.Common;

var connectionInfo = new KeyboardInteractiveConnectionInfo("serverip", 22, "username");

connectionInfo.AuthenticationPrompt += delegate(object sender, AuthenticationPromptEventArgs e)
    foreach (var prompt in e.Prompts)
        if (prompt.Request.Equals("password", StringComparison.InvariantCultureIgnoreCase))
            prompt.Response = "password";

using (var ssh = new SshClient(connectionInfo))
    label1.Text = "success";


The error I get is: (Value cannot be null.  Parameter name: "data")

   at Renci.SshNet.KeyboardInteractiveConnectionInfo.OnAuthenticate()
   at Renci.SshNet.ConnectionInfo.Authenticate(Session session)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.Connect()
   at WindowsFormsApplication1.Form1..ctor() in c:\users\klocke.hbwleads\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 34
   at WindowsFormsApplication1.Program.Main() in c:\users\klocke.hbwleads\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:line 18
   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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Jan 17, 2012 at 9:01 PM

So far... the problem is the line: if (prompt.Request.Equals("password", StringComparison.InvariantCultureIgnoreCase))

I looked at the prompt request and it was Password:.  I tried changing it to that, still didnt work.  So now I just add the password to the response no matter the prompt.  So far I am able to connect and Im about to try running some commands.

Jul 30, 2012 at 10:11 PM
Edited Jul 31, 2012 at 9:25 PM

I think it's supposed to be "Password: ".  Notice the extra space after the colon.

EDIT: Scratch that.  I'm getting the same thing and I'm going through powershell.

Aug 2, 2012 at 2:38 AM

Note that the prompt could also be "Password:" 


I got the same error with FreeBSD, and if you debug the code while connection is being established, you'll see that there's no space.