ssh2_auth_password example

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} */
  public static function factory($jail$settings) {
    $username = empty($settings['username']) ? '' : $settings['username'];
    $password = empty($settings['password']) ? '' : $settings['password'];
    $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname'];
    
sprintf(
                    /* translators: %s: hostname:port */
                    __( 'Failed to connect to SSH2 Server %s' ),
                    $this->options['hostname'] . ':' . $this->options['port']
                )
            );

            return false;
        }

        if ( ! $this->keys ) {
            if ( ! @ssh2_auth_password( $this->link, $this->options['username']$this->options['password'] ) ) {
                $this->errors->add(
                    'auth',
                    sprintf(
                        /* translators: %s: Username. */
                        __( 'Username/Password incorrect for %s' ),
                        $this->options['username']
                    )
                );

                return false;
            }
        }
Home | Imprint | This part of the site doesn't use cookies.