function SSH::connect

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/FileTransfer/SSH.php \Drupal\Core\FileTransfer\SSH::connect()
  2. 10 core/lib/Drupal/Core/FileTransfer/SSH.php \Drupal\Core\FileTransfer\SSH::connect()
  3. 11.x core/lib/Drupal/Core/FileTransfer/SSH.php \Drupal\Core\FileTransfer\SSH::connect()

Overrides FileTransfer::connect

File

core/lib/Drupal/Core/FileTransfer/SSH.php, line 24

Class

SSH
The SSH connection class for the update module.

Namespace

Drupal\Core\FileTransfer

Code

public function connect() {
    $this->connection = @ssh2_connect($this->hostname, $this->port);
    if (!$this->connection) {
        throw new FileTransferException('SSH Connection failed to @host:@port', 0, [
            '@host' => $this->hostname,
            '@port' => $this->port,
        ]);
    }
    if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) {
        throw new FileTransferException('The supplied username/password combination was not accepted.');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.