C# Centos 使用类库收藏

C#通过SharpSSH类库登陆远程linux服务器执行命令并得到回显

 public static string ssh(string ip, string root, string pass, string command)
 {

            SshStream ssh = new SshStream(ip, root, pass);
            ssh.Prompt = "#";
            ssh.RemoveTerminalEmulationCharacters = true; 
            string response = ssh.ReadResponse();
            ssh.Write(command);
            ssh.Flush();
            ssh.Write("/n");
            response = ssh.ReadResponse();
            //Console.WriteLine(response);
            return response;

  }

你可能感兴趣的:(C# Centos 使用类库收藏)