SSH connection from ASPNET to a unix server

jg.lalanne_at_gmail.com
Date: 06/14/05


Date: 14 Jun 2005 01:13:24 -0700

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



Relevant Pages

  • Re: Launch process on NT server
    ... The fact is that we want to control all the process from a UNIX ... windows, it's just a batch dos with the copy function. ... WINDOWS and ask for a batch process to launch that DOS copy command in ...
    (comp.unix.shell)
  • Re: Reading a list
    ... windows box to the unix box. ... The windows box does not allow any ... initiated conversations and the unix box ... box to launch an rsync periodically. ...
    (comp.lang.tcl)
  • Re: ADFS Development Issues
    ... One thing to keep in mind is that if a website is protected by ADFS V1, ... site to be automatically authenticated by our windows application so ... like a web service proxy. ... generated on the server. ...
    (microsoft.public.windows.server.active_directory)
  • Re: What is the more popular UNIX flavor?
    ... about my experience with Solaris and Cygwin. ... installing packages. ... needing eg tftp you only need to activate on a Unix system. ... probably need installing first on the equivalent Windows system. ...
    (comp.unix.questions)
  • Re: Five Architectural Flaws in Windows Solved In Mac OS X
    ... But it is still an improvement over Unix, wherein *any executable* can be highly privileged and interact with the user. ... The usual security precautions prevent unauthorized people from doing this, but that's true on Windows also. ... I just got thru upgrading the wifes Mac to Tiger and hpfs is the default. ... This is a more advanced design that Unixes have been trying to duplicate by adding thread support. ...
    (comp.sys.mac.advocacy)