在Unity3D項(xiàng)目開(kāi)發(fā)工具時(shí)需要用到SSH連接遠(yuǎn)程Linux服務(wù)器執(zhí)行命令,找到SharpSSH鏈接庫(kù)后,通過(guò)此方法就可使用。
創(chuàng)新互聯(lián)是專業(yè)的輝南網(wǎng)站建設(shè)公司,輝南接單;提供網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站,網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行輝南網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
////// SSH登錄遠(yuǎn)程Linux服務(wù)器,并運(yùn)行指令 /// /// 遠(yuǎn)程Linux服務(wù)器IP或域名 /// 賬號(hào)名 /// 賬號(hào)密碼 /// 命令 ///public static bool RunSSHCommands(String host, String username, String password, String[] commands) { if (commands == null || commands.Length == 0) return false; try { SshExec exec = new SshExec(host, username); exec.Password = password; //XXLog.Log(String.Format("[{0}]Connecting...", host)); exec.Connect(); //XXLog.Log("OK"); foreach (String command in commands) { if (command == null || command.Trim().Length == 0) continue; string output = exec.RunCommand(command); //XXLog.Log(output); } //XXLog.Log("Disconnecting..."); exec.Close(); //XXLog.Log("OK"); return true; } catch (Exception e) { XXLog.Log(e.Message); return false; } }