forwardOut() fails with Connection refused error with some remote hosts
See original GitHub issueWhen I try to forward a local port to a remote host with this module and some hosts refuse to connect and I get the following error (DEBUG):
Error: (SSH) Channel open failure: Connection refused
at SSH2Stream.onFailure (c:\vncclient\node_modules\ssh2\lib\client.js:1186:13)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at SSH2Stream.emit (events.js:211:7)
at parsePacket (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:3708:10)
at SSH2Stream._transform (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:669:13)
at SSH2Stream.Transform._read (_stream_transform.js:186:10)
at SSH2Stream._read (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:251:15)
at SSH2Stream.Transform._write (_stream_transform.js:174:12)
at doWrite (_stream_writable.js:387:12) +0ms
the ‘ready’ event is hit but then the forwardOut() fails and therefore the sshstream cannot be piped to the connection.
This is my implementation I provide the configuration and wait for the ‘listening’ event and then create a new connection to the tunnel.
const config = {
username: 'myuser',
privateKey: fs.readFileSync('file.ppk'),
passphrase: 'mypasphrase',
host: target_host,
dstPort: 5900,
localPort: 0,
localHost: 'localhost',
readyTimeout: 99999,
srcHost: 'localhost',
port: 22,
};
sshtunnel = tunnel(config, function (error, server) {
if (error) {console.log('error');
});
sshtunnel.on('listening', function () {
net.createConnection(sshtunnel.address().port, sshtunnel.address().address, function () {
});
});
The above code works with some hosts but others Refuse, and all host are identical. I already spent 3 full days on this issue.
This is the complete debug output from tunnel-ssh:
tunnel-ssh sshConnection:ready +224ms
Error found on ssh tunnel: { Error: (SSH) Channel open failure: Connection refused
at SSH2Stream.onFailure (c:\vncclient\node_modules\ssh2\lib\client.js:1186:13)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at SSH2Stream.emit (events.js:211:7)
at parsePacket (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:3708:10)
at SSH2Stream._transform (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:669:13)
at SSH2Stream.Transform._read (_stream_transform.js:186:10)
at SSH2Stream._read (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:251:15)
at SSH2Stream.Transform._write (_stream_transform.js:174:12)
at doWrite (_stream_writable.js:387:12) reason: 'CONNECT_FAILED', lang: '' }
tunnel-ssh Destination port: { Error: (SSH) Channel open failure: Connection refused
at SSH2Stream.onFailure (c:\vncclient\node_modules\ssh2\lib\client.js:1186:13)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at SSH2Stream.emit (events.js:211:7)
at parsePacket (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:3708:10)
at SSH2Stream._transform (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:669:13)
at SSH2Stream.Transform._read (_stream_transform.js:186:10)
at SSH2Stream._read (c:\vncclient\node_modules\ssh2-streams\lib\ssh.js:251:15)
at SSH2Stream.Transform._write (_stream_transform.js:174:12)
at doWrite (_stream_writable.js:387:12) reason: 'CONNECT_FAILED', lang: '' } +6ms
I’m running on a windows server 2012 with Node.js version 8.9.0 and the remote hosts are Linux 2.6.15.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:13 (9 by maintainers)
Top Results From Across the Web
ssh tunnel refusing connections with "channel 2: open failed"
Problem solved: $ ssh -L 7000:127.0.0.1:7000 user@host -N -v -v ...apparently, 'localhost' was not liked by the remote host. Yet, remote /etc/hosts contains ......
Read more >How to Fix the SSH "Connection Refused" Error
Then we'll explain some common reasons your connection may be refused, including in PuTTY. Finally, we'll provide some troubleshooting tips.
Read more >Forward X11 failed: Network error: Connection refused
I want to run startx via PuTTY and Xming. But, it produces this error: PuTTY X11 proxy: unable to connect to forwarded X...
Read more >ssh2
Server events; Server methods; Connection events ... Host: 127.0.0.1:8000 ... console.log('FIRST :: forwardOut error: ' + err);.
Read more >Troubleshooting
Issue the following command to obtain the current level of Java: ... Connection to remote machine refused, Older version of the keys is...
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
@aberbegall i’d try adding
ssh.shell()
and then dossh.forwardOut()
inside the shell callback and see if that works.Glad you found a solution for you problem.
On 8 November 2017 at 03:25, Agustin Berbegall notifications@github.com wrote: