Based on Renci.SshNet library. You must add this library to your project before use this wrapper.
https://github.com/sshnet/SSH.NET
For FILE PATHS I'm using HostingEnvironment.MapPath(...), make sure is it OK for you.
Error output goes to Console.WrietLine(), edit Error(...) method to change this behavior.
Recommended to use absolute paths for downloading/uploading
- ExecuteCommand
- UploadFile
- DownloadFile
- Reboot
- CreateConnectionInfo
using (var con = new SshNetWrapper(privateKeyPath, serverIp))
{
var cmd = con.ExecuteCommand("sudo...");
Console.WriteLine(cmd.Result);
}
SshCommand cmdResult;
var runtimeSuccess = true;
using (var con = new SshNetWrapper(privateKeyPath, serverIp))
{
cmdResult = con.ExecuteCommand("sudo....", ref ok);
con.DownloadFile("remotePath", "localPath", ref runtimeSuccess)
}
Console.WriteLine(runtimeSuccess.ToString());
Console.WriteLine(cmdResult.Result);