/** * Connect to the host via all tunnel nodes * * @return Connection|null */ protected function connect() { // Connect to target host $this->status(Phase::CONNECTION(), 0, 0, "Connecting to target host " . $this->host->getHostname() . ':' . $this->host->getPort()); $con = new Connection($this->host->getHostname(), $this->host->getPort(), $this->host->getCredential()); $con->setLogger($this->logger); if (!$con->connect()) { $this->status(Phase::ERROR(), 0, 0, "Failed to connect to target host"); $con->disconnectChain(); return null; } if (!$con->authenticate()) { $this->status(Phase::ERROR(), 0, 0, "Failed to authenticate on target host"); $con->disconnectChain(); return null; } return $con; }