ssh = new Net_SSH2($server,$port); if ($cer) { include ('Crypt/RSA.php'); $key = new Crypt_RSA(); $key->loadKey(file_get_contents($password)); } else { $key = $password; } if (!$this->ssh->login($username, $key)) { return false; // Login Failed }else { return true; } } /** * 执行SSH命令 */ public function exec($com){ return $this->ssh->exec($com); } /** * 关闭SSH连接 */ public function close(){ return $this->ssh->disconnect(); } }