ssh2_connect example



    /** * Connects filesystem. * * @since 2.7.0 * * @return bool True on success, false on failure. */
    public function connect() {
        if ( ! $this->keys ) {
            $this->link = @ssh2_connect( $this->options['hostname']$this->options['port'] );
        } else {
            $this->link = @ssh2_connect( $this->options['hostname']$this->options['port']$this->options['hostkey'] );
        }

        if ( ! $this->link ) {
            $this->errors->add(
                'connect',
                sprintf(
                    /* translators: %s: hostname:port */
                    __( 'Failed to connect to SSH2 Server %s' ),
                    $this->options['hostname'] . ':' . $this->options['port']
                )
    $this->username = $username;
    $this->password = $password;
    $this->hostname = $hostname;
    $this->port = $port;
    parent::__construct($jail);
  }

  /** * {@inheritdoc} */
  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.');
    }
  }

  /** * {@inheritdoc} */
  
Home | Imprint | This part of the site doesn't use cookies.