I have below code for run a putty with authentication from C#
private void button1_Click(object sender, EventArgs e)
{
ProcessStartInfo cmd = new ProcessStartInfo();
cmd.FileName = "putty.exe";
cmd.UseShellExecute = false;
cmd.RedirectStandardInput = true;
cmd.RedirectStandardOutput = true;
cmd.Arguments = "-ssh " + username + host+ " -pw " + upassword;
using (Process process = Process.Start(cmd))
{
process.WaitForExit();
}
}
The above code is launching putty and authenticating the user and password. I want to execute some commands after launching the putty. I used below code
private void button1_Click(object sender, EventArgs e)
{
ProcessStartInfo cmd = new ProcessStartInfo();
cmd.FileName = "putty.exe";
cmd.UseShellExecute = false;
cmd.RedirectStandardInput = true;
cmd.RedirectStandardOutput = true;
cmd.Arguments = "-ssh " + username + host+ " -pw " + upassword+ "-m "+path;;
using (Process process = Process.Start(cmd))
{
process.WaitForExit();
}
}
The path variable contains the location of the file and file contain below text in it
ssh webhostname
While executing the above code, putty is launched but during authentication putty terminated with message "Unauthorized access to this machine is prohibited"
Is there anyway we can run the commands in putty from a file?