Esempio n. 1
0
 /**
  * Open the SSH connection
  *
  * @param Plum\Server\ServerInterface $server
  */
 protected function connect(ServerInterface $server)
 {
     $ssh = new Net_SSH2($server->getHost(), $server->getPort());
     if (!$ssh->login($server->getUser(), $server->getPassword())) {
         throw new SshException(sprintf('Authorization failed for user "%s"', $server->getUser()));
     }
     $this->con = $ssh;
 }
Esempio n. 2
0
 /**
  * Open the SSH connection
  *
  * @param Plum\Server\ServerInterface $server
  */
 protected function connect(ServerInterface $server)
 {
     if (false === function_exists('ssh2_connect')) {
         throw new \RuntimeException('The "ssh2_connect" function does not exist.');
     }
     $con = ssh2_connect($server->getHost(), $server->getPort());
     if (false === $con) {
         throw new SshException(sprintf('Cannot connect to server "%s"', $server->getHost()));
     }
     if (false === ssh2_auth_password($con, $server->getUser(), $server->getPassword())) {
         throw new SshException(sprintf('Authorization failed for user "%s"', $server->getUser()));
     }
     $this->con = $con;
 }