How do I answer the prompt in a plink command?


Jul 18, 2017
Programming Experience
Good Morning,

Whenever I use PuTTY to open a window to my Lunix device for the first time, I always see a prompt that says "server's host key does not match...etc".

This occurs every time I re-image a device or I have a new device.

I am currently trying to send a "plink" command to a new device in a Windows 10 environment to look at the ifconfig of a Lunix box.
If I enter the following on a Windows command prompt:

echo y | plink.exe -ssh -pw root root@ -P 22 ifconfig

I get everything back properly.
If I do not use the "echo y | ", I will get the prompt seen above.
I do not want to have to enter anything in a command prompt window. I am trying to do this in C#. My code is as follows:

using System;
using System.Windows.Forms;

namespace WindowsFormsApp1
public partial class Form1 : Form
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
string PuttyDoCmd = "C:\\Program Files (x86)\\Putty\\plink.exe";
string output = string.Empty;
string error = string.Empty;

public Form1()

private void TEST_Click(object sender, EventArgs e)
string arguments = @" -ssh -batch -pw root root@ -P 22 ifconfig";
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = PuttyDoCmd;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = arguments;
process.StartInfo = startInfo;
output = process.StandardOutput.ReadToEnd();
error = process.StandardError.ReadToEnd();


I need to be able to answer the prompt and don't know how to do that.
Can someone direct me properly?

L. Madeux...
Top Bottom