Tunnel with forwardOut question.
See original GitHub issueHi,
First I wanted to say that I am loving this library. Fantastic work!!
I have a question because I have a server at a remote location that I would like to tunnel through to. I’m not sure that it’s that unusual and I’m pretty sure I must be missing something here. There is a firewall in between that uses a key on port 222. Anyway, the way I normally do it is with a command like:
ssh -L localhost:2221:[SERVER IP]:22 -p 222 [F/WALL UNAME]@[F/WALL IP]
Then I just ssh into it:
ssh -p 2221 [SERVER UNAME]@localhost
This is an example of what I’m trying to do.
var fs = require('fs'),
Connection = require('ssh2');
var c1 = new Connection();
c1.connect({
host: '[F/WALL IP]',
port: 222,
username: '[F/WALL UNAME]',
privateKey: require('fs').readFileSync('./keys/sample.key')
});
c1.on('ready', function(){
c1.forwardOut('localhost', 2221, '[SERVER IP]', 22, function(err, stream) {
if(err) throw err;
console.log('ForwardOut Ready!');
var c2 = new Connection();
c2.connect({
host: 'localhost',
port: 2221,
username: '[SERVER UNAME]',
password: '[SERVER PASSWORD]'
});
c2.on('ready', function(){
console.log('Connected!');
});
c2.on('error', function(err) {
console.log('Connection :: error :: ' + err);
});
})
});
c1.on('error', function(err) {
console.log('Connection :: error :: ' + err);
});
The ouput I get is:
ForwardOut Ready! Connection :: error :: Error: connect ECONNREFUSED
Is there anything glaring that you can see I’m missing?
Cheers, Paul
Issue Analytics
- State:
- Created 10 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
how do I use npm module ssh2 to tunnel a port - Stack Overflow
I'm now trying to also tunnel a port over the same ssh connection but ... stream) => { // console.log( // "ssh forwardOut...
Read more >SSH Tunneling: Client Command & Server Configuration
The problem is that port forwarding can in practice only be prevented by a server or firewall. An enterprise cannot control all servers...
Read more >ASA NAT Question - Anyconnect full-tunnel to internal server via ...
As the title says, I need to access an internal server on the inside interface via it's public IP on the outside interface...
Read more >How to problem solve Bi-directional Forwarding Detection (BFD)
Step 1: Detach the MPLS-VC interface attached to the configured virtual-switch · Step 2: Delete the static-virtual cirtuit. · Step 3: Delete the ......
Read more >Understand GRE Tunnel Keepalives - Cisco
This mechanism causes the keepalive response to forward out the physical interface rather than the tunnel interface. This means that the GRE ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Published ssh-http-agent:
I thought Node’s
http
would callref
andunref
though it doesn’t seem to…@jpillora and anyone else who may be interested:
Here’s an example HTTP/HTTPS Agent implementation that tunnels requests over SSH. It could be improved a bit (e.g. actual/proper
ref()
/unref()
handling) and it might be possible to simplify it a bit because for example, I think node may retry requests that never received a socket, so we may not need to manually handle the'ready'
event handlers.Then use like: