public async Task <SshCommandResult> Run(string commandText) { System.Console.WriteLine($"[SSH] Executing: {commandText}"); var command = sshClient.CreateCommand(commandText); await Task.Factory.FromAsync(command.BeginExecute, command.EndExecute, null).ConfigureAwait(false); return(new SshCommandResult(command.ExitStatus, command.Result, command.Error)); }
public ListResult GetListResult() { var host = Host; var username = Username; var password = Password; using (var sshClient = new Renci.SshNet.SshClient(host, username, password)) { sshClient.Connect(); var cmd = sshClient.CreateCommand("tdtool --list", Encoding.UTF8); var commandResult = cmd.Execute(); var listDeserializer = new ListDeserializer(new SensorListDeserializer()); var result = listDeserializer.Deserialize(commandResult); return result; } }
public static void AdoptDevice(string IP, string ControllerURL = "http://unifi.scharsich.dev:8080/inform") { using (var client = new Renci.SshNet.SshClient(IP, "ubnt", "ubnt")) { client.Connect(); var cmd = client.CreateCommand("mca-cli-op set-inform " + ControllerURL); cmd.Execute(); if (cmd.ExitStatus != 0) { MessageBox.Show(cmd.Error); } else { MessageBox.Show("Device " + IP + " adopted."); } client.Disconnect(); } }