parro-it / open-ssh-tunnel

Easy ssh2 tunneling
MIT License
53 stars 7 forks source link

Connection gets always closed #9

Open aberbegall opened 7 years ago

aberbegall commented 7 years ago

As alternative to tunnel-ssh I'm trying to use this module but I always get this debug output:

open-ssh-tunnel ssh tunnel is ready. +328ms
open-ssh-tunnel ssh tunnel is closed. +4ms
open-ssh-tunnel ssh tunnel is disconnected. +
open-ssh-tunnel ssh tunnel is closed. +1ms
open-ssh-tunnel port forward timed out. +1ms

This is the code I'm using in order to redirect port 5900 on 'IP remote' to a local random port and listen on another local random port.

async function openATunnel() {
     const server = await openSshTunnel({
        username: 'myuser',
        privateKey: fs.readFileSync('file.ppk'),
        passphrase: 'mypassphrase',
        host: 'IP remote',
        dstPort: 5900,
        localPort: 0,
        port: 22,
        srcPort: 0
        });
       // THIS LINE IS NEVER REACHED!!
       server.close();
}

openATunnel().catch(() => {});

I set the srcPort and localPort to 0 to obtain a random port.

What am I doing wrong?

parro-it commented 6 years ago

openATunnel().catch(() => {});

You are ignoring any error you receive by using .catch(() => {});. Could you write the error to console and retry? .catch(err => console.log(err));