J
jg.lalanne
Hi,
I have developped a web service in C# .NET that has to launch a unix
script on a AIX machine. I have installed on my windows 2003 server the
cygwin environment with the ssh.exe utility.
I have created a RSA public key without passphrase and appended it in
the authorized_keys file on the unix server.
When I launch my C:\cygwin\bin\ssh.exe unixlogin@unixserverhost 'uname
-a' from a doc command prompt, it works correctly without asking me a
password.
I do the same with the following code from a C# console project, and it
works correctly as well :
_____________________________________________________
string commandText = "C:\\cygwin\\bin\\ssh.exe";
string argsText = "login@server 'uname -a'";
Process objProcess = new Process();
objProcess.StartInfo.FileName = commandText;
objProcess.StartInfo.Arguments = argsText;
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
objProcess.StartInfo.CreateNoWindow = false;
objProcess.StartInfo.RedirectStandardOutput = true;
objProcess.StartInfo.RedirectStandardError = true;
objProcess.StartInfo.UseShellExecute = false;
try
{
objProcess.Start();
objProcess.WaitForExit();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
string error = objProcess.StandardError.ReadToEnd();
string output = objProcess.StandardOutput.ReadToEnd();
Console.Out.WriteLine("output = " + output );
---------------------------------------------------------
When I put the same code in my Web Service, it does not work anymore.
This is, I supposed, because of the ASPNET profile that is different
from the window user profile used for the RSA key generation.
That was I tried to use the impersonation to force the good user
profile in my web service code. But it does not work either....
Does anyone of you manage to do such a SSH communication from ASPNET to
a unix server ?
Thanks in advance for your help.
Best Regards
Jean-Guillaume LALANNE
I have developped a web service in C# .NET that has to launch a unix
script on a AIX machine. I have installed on my windows 2003 server the
cygwin environment with the ssh.exe utility.
I have created a RSA public key without passphrase and appended it in
the authorized_keys file on the unix server.
When I launch my C:\cygwin\bin\ssh.exe unixlogin@unixserverhost 'uname
-a' from a doc command prompt, it works correctly without asking me a
password.
I do the same with the following code from a C# console project, and it
works correctly as well :
_____________________________________________________
string commandText = "C:\\cygwin\\bin\\ssh.exe";
string argsText = "login@server 'uname -a'";
Process objProcess = new Process();
objProcess.StartInfo.FileName = commandText;
objProcess.StartInfo.Arguments = argsText;
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
objProcess.StartInfo.CreateNoWindow = false;
objProcess.StartInfo.RedirectStandardOutput = true;
objProcess.StartInfo.RedirectStandardError = true;
objProcess.StartInfo.UseShellExecute = false;
try
{
objProcess.Start();
objProcess.WaitForExit();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
string error = objProcess.StandardError.ReadToEnd();
string output = objProcess.StandardOutput.ReadToEnd();
Console.Out.WriteLine("output = " + output );
---------------------------------------------------------
When I put the same code in my Web Service, it does not work anymore.
This is, I supposed, because of the ASPNET profile that is different
from the window user profile used for the RSA key generation.
That was I tried to use the impersonation to force the good user
profile in my web service code. But it does not work either....
Does anyone of you manage to do such a SSH communication from ASPNET to
a unix server ?
Thanks in advance for your help.
Best Regards
Jean-Guillaume LALANNE