Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow alternate sftp-server paths for client connections #1296

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 frylock@192.168.100.100

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'
});

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants