i have been looking @ using ssh2 module sftp shipping of logs. cloud service hosting our app uses rotating ip address range. wanting integrate socks5 proxy service giving static ip address. i'm using socksjs module socks5 connection established, i'm getting connection proxy, think have injecting of socket connection sftp use wrong.
cheers,
nik
var sockconn = new socksconnection(conntargetsettings, connproxysettings); conntargetsettings.sock = sockconn.outsocket; var conn = new ssh2.client(); conn.on("ready", function() { conn.sftp(function(err, sftp) { if (err) throw err; // you'll able use sftp here sftp.readdir("/", function(err, list) { if (err) throw err; // list directory in console console.dir(list); // not forget close connection, otherwise you'll troubles conn.end(); }); // use sftp execute tasks .unlink or chmod etc }); }).connect(conntargetsettings);
you can use socksv5 library(it's creator of ssh2) connect throw socks5 proxy.
example:
var socks = require('socksv5'), sshclient = require('ssh2').client; socks.connect({ host: 'ssh.example.org', // destination port: 22, proxyhost: '127.0.0.1', proxyport: 1080, auths: [ socks.auth.none() ] }, function(socket) { var conn = new sshclient(); conn.on('ready', function() { conn.exec('uptime', function(err, stream) { if (err) throw err; stream.on('close', function(code, signal) { conn.end(); }).on('data', function(data) { console.log('stdout: ' + data); }).stderr.on('data', function(data) { console.log('stderr: ' + data); }); }); }).connect({ sock: socket, username: 'frylock', privatekey: require('fs').readfilesync('/here/is/my/key') }); });
Comments
Post a Comment