connect(config) {
    let doReady, listeners;
    return new Promise((resolve, reject) => {
      listeners = addTempListeners(this, 'getConnection', reject);
      if (config.debug) {
        this.debug = config.debug;
        this.debugMsg('connect: Debugging turned on');
        this.debugMsg(`ssh2-sftp-client Version: ${this.version} `, process.versions);
      }
      this.promiseLimit = config.promiseLimit ?? 10;

      doReady = () => {
        this.client.sftp((err, sftp) => {
          if (err) {
            reject(this.fmtError(err));
          } else {
            this.sftp = sftp;
            resolve(sftp);
          }
        });
      };
      this.on('ready', doReady);

      try {
        if (this.sftp) {
          reject(
            this.fmtError(
              'An existing SFTP connection is already defined',
              'connect',
              errorCode.connect,
            ),
          );
        } else {
          this.client.connect(config);
        }
      } catch (err) {
        this.end();
        reject(err);
      }
    }).finally(() => {
      this.removeListener('ready', doReady);
      removeTempListeners(this, listeners, 'getConnection');
    });
  }
Create a new SFTP connection to a remote SFTP server.
The connection options are the same as those offered
by the underlying SSH2 module.

@param {Object} config - an SFTP configuration object

@return {Promise<Object>} which will resolve to an sftp client object