Skip to content

kouweizhong/.NET-C-Renci.SshNet-Wrapper-SIMPLE

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

.NET-C-Renci.SshNet-Wrapper-SIMPLE

SSH, SFTP robust synchronous wrapper designed for SIMPLE use.

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

PUBLIC METHODS:

  • ExecuteCommand
  • UploadFile
  • DownloadFile
  • Reboot
  • CreateConnectionInfo

BASIC USAGE

using (var con = new SshNetWrapper(privateKeyPath, serverIp))
{
    var cmd = con.ExecuteCommand("sudo...");
    Console.WriteLine(cmd.Result);
}

RECOMMEND USAGE

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);

About

Simple robust wrapper for Renci.SshNet library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%