How to use the ssh2-streams.SFTPStream function in ssh2-streams

To help you get started, we’ve selected a few ssh2-streams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SchoofsKelvin / vscode-sshfs / src / connect.ts View on Github external
}
  // If the user wants sudo, we'll first convert this shell into a sudo shell
  if (config.sftpSudo) await startSudo(shell, config, config.sftpSudo);
  shell.write(`echo SFTP READY\n`);
  // Wait until we see "SFTP READY" (skipping welcome messages etc)
  await new Promise((ready, nvm) => {
    const handler = (data: string | Buffer) => {
      if (data.toString().trim() !== 'SFTP READY') return;
      shell.stdout.removeListener('data', handler);
      ready();
    };
    shell.stdout.on('data', handler);
    shell.on('close', nvm);
  });
  // Start sftpCommand (e.g. /usr/lib/openssh/sftp-server) and wrap everything nicely
  const sftps = new SFTPStream({ debug: config.debug });
  shell.pipe(sftps).pipe(shell);
  const sftp = new SFTPWrapper(sftps);
  await toPromise(cb => shell.write(`${cmd}\n`, cb));
  return sftp;
}

ssh2-streams

SSH2 and SFTP(v3) client/server protocol streams for node.js

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis