0

What would be the easiest way to do this where there isn't any commerical products involved. I currently have my code setup like this and it isn't working out. At the moment UNIXCOMPUTERNAME and UNIXPASSWORD is hardcoded into the program just for my personal testing purposes.

This is for a asp.net web page and this is located in the codebehind file. I either want to get this code to work or I want to find a SSH library. I am using Visual Studio Web Developer Express, so it seems that is also limiting me.

Dim unixVariables(2) As String
    nameLabel.Text = FQDN.Text
    Dim Proc As New System.Diagnostics.Process
    Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
    Proc.StartInfo.Arguments = "-pw " & UNIXPASSWORD & " " & UNIXUSERNAME & "@" & UNIXCOMPUTERNAME & " ls > output.txt"
    Proc.StartInfo.RedirectStandardInput = True
    Proc.StartInfo.RedirectStandardOutput = True
    Proc.StartInfo.UseShellExecute = False
    Proc.Start()
    ' Pause for script to run
    System.Threading.Thread.Sleep(100)
    Proc.Close()

1 Answer 1

1

As you seem to be aware, Microsoft does not include an SSH library as part of the .NET framework. There are however some free libraries out there, such as:

http://www.codeproject.com/Articles/11966/sharpSsh-A-Secure-Shell-SSH-library-for-NET

http://sshnet.codeplex.com/

http://www.routrek.co.jp/en/product/varaterm/granados.html

Having never used them, I can't vouch for them or recommend any over any other. However, if you want to simply execute a command line as you showed in your question, that should work fine too. Since you didn't specify what exactly wasn't working about that solution, it's hard to tell you how to fix it. You do need to make sure that you can execute that command as the same user as the one under which your ASP project is running.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for not being more specific. I am currently on a windows system developing this and I am using PUTTY to monitor the UNIX system that I want to connect to. What I have in the above code is the command "ls" being sent to a file called "output.txt". I'm not getting any error when I execute this, but the file is not being created -- so it is making it difficult to track down where the issue is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.