4 Replies - 356 Views - Last Post: 08 May 2019 - 06:02 AM Rate Topic: -----

#1 Lmadeux   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 08-February 18

How do I answer Putty question

Posted 07 May 2019 - 01:10 PM

I have an application that is trying to communicate with an external device via ether-net cable.
Using the following code:

    Process proc = null;
    string er="";
    string o="";
    ProcessStartInfo test = new ProcessStartInfo("C:\\Program Files (x86)\\PuTTY\\plink.exe", "-ssh -batch -pw root [email protected]:22 ifconfig");
    test.UseShellExecute = false;
    test.RedirectStandardOutput = true;
    test.RedirectStandardError = true;
    test.CreateNoWindow = true;

    proc = Process.Start(test);
    er = proc.StandardError.ReadToEnd();
    o = proc.StandardOutput.ReadToEnd();



I receive back:
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1024 7b:e5:6f:a7:f4:f9:81:62:5c:e3:1f:bf:8b:57:6c:5a
If you trust this host, hit Yes to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, hit No.
If you do not trust this host, hit Cancel to abandon the
connection.

How do I answer this question automatically to "trust" the host?

Thanks

Is This A Good Question/Topic? 1
  • +

Replies To: How do I answer Putty question

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6963
  • View blog
  • Posts: 23,674
  • Joined: 05-May 12

Re: How do I answer Putty question

Posted 07 May 2019 - 01:40 PM

In general, when you need to interact with a console program, you'll need to try to redirect standard input as well and write into the input pipe of that process.

The big question here, though, is why are trying to go through Putty? Why not use SSH.NET and write code against classes directly? Also, if you have the latest (preview?) builds of Windows 10, OpenSSH should be built in -- that means you should be able to use whatever that build offers up in terms of a .NET compatibility layer.
Was This Post Helpful? 0
  • +
  • -

#3 Lmadeux   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 08-February 18

Re: How do I answer Putty question

Posted 08 May 2019 - 04:48 AM

This is legacy software.
They are using PuTTY - not my choice.
At any rate, I get the stated message back - but how do I provide an answer?

Thanks...
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2869
  • View blog
  • Posts: 11,233
  • Joined: 03-December 12

Re: How do I answer Putty question

Posted 08 May 2019 - 05:16 AM

If they are already using putty, then they also have the ability to answer those responses. So, it doesn't make sense to me on how you can't see that.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6963
  • View blog
  • Posts: 23,674
  • Joined: 05-May 12

Re: How do I answer Putty question

Posted 08 May 2019 - 06:02 AM

In other words, if they are already using PuTTY, they must have already connected to that server at least once manually. During that first manual connection, they could have responded yes to save the machine key.

Anyway, I did tell you in my first paragraph how you would respond to PuTTY:

View PostSkydiver, on 07 May 2019 - 04:40 PM, said:

In general, when you need to interact with a console program, you'll need to try to redirect standard input as well and write into the input pipe of that process.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1