agebrock / reverse-tunnel-ssh

Easy reverse tunnel
MIT License
42 stars 12 forks source link

Empty response #1

Closed timdp closed 7 years ago

timdp commented 7 years ago

I have a remotehost with GatewayPorts yes configured. I'm able to set up reverse tunneling to http://localhost:8000/ by running ssh remotehost -R 8888:localhost:8000. I'm now looking to reproduce that command in Node without spawning ssh.

With the code below, browsing to http://remotehost:8888/ gives me an empty response.

tunnel({
  host: 'remotehost',
  username: username,
  privateKey: privateKey,
  dstHost: '0.0.0.0',
  dstPort: 8888,
  localPort: 8000
}, function (err, server) {
  if (err) {
    throw err
  }
})

I also tried adding keepAlive: true. It didn't seem to change much.

I also looked at your index.js. I tried setting DEBUG=* but I think you're using the debug module wrong. If I turn it into require('debug')('reverse-tunnel-ssh'), I get some logging: ready happens once as expected and then every connection logs a tcp connection.

Finally, when is my callback supposed to be called? Looking at the code, it waits for the first incoming connection. Instead, I'd like to pass a continuation for when the tunnel has been set up, keep the tunnel open, and continue my script, which doesn't seem to be possible.

Could you perhaps share a typical usage example? Thanks.

agebrock commented 7 years ago

Hi there the first difference i see is that you use localhost in your ssh script and 0.0.0.0. To be honest i don't know if that makes any difference.

What kind of server do you use ? Linux with ssh_config setup ?

agebrock commented 7 years ago

Can not reproduce.