In the Unity3d Project development tool, you need to use SSH to connect to the remote Linux Server Execution command, after locating the SHARPSSH link library, this method is available.
/// <summary> /// ssh log in to a remote Linux server and run instructions /// </summary> /// <param name= "host" > Remote linux server IP or domain name </param> /// <param name= "username" > account name </param> /// <param name= "password" > account password </param> /// < Param name= "Commands" > Commands </param> /// <returns></returns> 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; } }
This article is from the "zl1030 Records" blog, so be sure to keep this source http://zl1030.blog.51cto.com/274507/1926176
C # establishes an SSH connection to a Linux server and executes commands via the SHARPSSH library