Skip to content

Conversation

@joaomariord
Copy link

This PR allows the client to select an alternate path for clients to connect sftp to.

A usage of this SSH facility is to use alternate sftp-servers or to do privilege escalation on systems that support it, the OpenSSH SFTP tool supports this with the -s flag.

Usage (in OpenSSH SFTP):
sftp -s "/usr/bin/sudo /usr/libexec/sftp-server" -p 22 [email protected]

Usage in SSH2 lib:

const { Client } = require('ssh2');

const conn = new Client();
conn.on('ready', () => {
  console.log('Client :: ready');
  conn.sftp((err, sftp) => {
    if (err) throw err;
    sftp.readdir('foo', (err, list) => {
      if (err) throw err;
      console.dir(list);
      conn.end();
    });
  }, { command: '/usr/bin/sudo /usr/libexec/sftp-server' } );
}).connect({
  host: '192.168.100.100',
  port: 22,
  username: 'frylock',
  password: 'nodejsrules'
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants