PHP ssh2 Extension can find the mother of
host = $host; $this->user = $user; $this->password = $password; $this->connection = Ssh2_connect ($this->host, 22); if (! $this->connection) die (' connection to '. $host. ': Failed '); $this->auth_methods = Ssh2_auth_none ($this->connection, $this->user); /** * Execute shell command * @return Code 101: Authentication failed * 102: Logon to remote server via password failed * 103:shell Command Execution failed * 200: Operation succeeded */Public Function Execshell ($shell) {if (In_array (' Password ', $this->auth_methods)) {if (Ssh2_auth_password ($this->connection, $this->user, $this->password)) { $stream = Ssh2_exec ($this->connection, $shell); Execute PHP stream_set_blocking ($stream, true); Gets the content after the PWD is executed if ($stream = = = FALSE) {$this->data[' msg '] = ' shell command execution failed '; } else {$this->data [' code '] = 200; $this->data [' msg '] = stream_get_contents ($stream); }} else {$this->data [' code '] = 102; $this->data [' msg '] = ' failed to log on to the remote server by password '; }} else {$this->data [' code '] = 101; $this->data [' msg '] = ' authentication failed '; } return $this->data; }} $host = '; $user = '; $passwd = '; $sshObj = new Ssh ($host, $user, $passwd); $rs = $sshObj->execshell (' pwd '); Var_dump ($ RS);