I needed a SSH framework for a program I am writing for my school. There are quite a few out there for .Net but I ended up going with the one from http://sshnet.codeplex.com. It requires .Net 3.5 or 4.0, but its ease of use makes this not a problem. Below is a example of code using the pre-built binary for .Net 3.5, this code connects to a SSH server, then runs a command and stores the result in a string called ‘temp_holding’.
Renci.SshNet.SshClient MysshClient = new Renci.SshNet.SshClient(server, username, password); //these are varibles of strings
try{
MysshClient.Connect();
}catch{
//Something in here failed
return;
}
Renci.SshNet.SshCommand MyRanCommand = MysshClient.RunCommand(“pwd”);
lock (locker){
string temp_holding = MyRanCommand.Result;
}