server fail to bind "forwardIn" port
See original GitHub issueHi. Thanks mscdex for this module. I can’t understand why the code below work well when pointing to a real ssh server and fail when pointing to a node ssh2 mscdex server
I hope i’ve made a mistake and it’s a a bug or a limitation …
Requiring some serious help dude ! thanks in advance !
var ssh2 = require('ssh2');
var utils = ssh2.utils;
var fs = require('fs');
var keygen = require('ssh-keygen');
var ssh2Client = require('ssh2').Client;
// Pointing on mscdex ssh2 server
// run that
// then netstat -antp | grep 8000 -> KO
var clientDstKo = {
ip:'127.0.0.1',
port:23,
username:'foo',
password:'bar'
};
// Pointing on classical linux ssh daemon
// run that
// then netstat -antp | grep 8000 -> OK
// then telnet localhost port 8000 and everything is fine
var clientDstOk = {
ip:'127.0.0.1',
port:22,
username:'realuser',
password:'changeme'
};
// just change this to clientDstKo if you wanna reproduce the problem
var clientDst = clientDstOk;
var onClientConnected = function(client,info) {
console.log('Server: client connected (%s)',info.ip);
client
.on('authentication', function(ctx) {
if (ctx.method === 'password' && ctx.username === 'foo'&& ctx.password === 'bar') return ctx.accept();
ctx.reject();
})
.on('ready', function() {
client.on('request',function(accept,reject,name,info) {
console.log('Server: request event fired:',name,info);
accept();
});
});
};
var start = function(privateKey) {
new ssh2.Server({
privateKey: privateKey,
//debug:console.log
},onClientConnected)
.listen(23, '127.0.0.1', function() {
var client = new ssh2Client();
client.on('tcp connection', function(details,accept,reject) {
console.log('Client: tcp connection event fired, AS EXPECTED ! exiting ..',JSON.stringify(details));
process.exit(0);
});
client.on('ready', function() {
console.log('Client: ready event fired');
this.forwardIn('localhost', 8000, function (err, portBinded) {
if (err) return console.log(err.message);
console.log('Client: server supposed to accept forwardIn port %s',portBinded);
console.log('Now you are supposed to see port 8000 listening on localhost, please telnet localhost 8000');
return true;
});
}).connect({
host: clientDst.ip,
port: clientDst.port,
username:clientDst.username,
password:clientDst.password,
//debug:console.log
});
});
};
keygen({
password: false,
read: true,
destroy:true
}, function(err, out){
if(err) return cb(err);
start(out.key);
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to Fix Minecraft Server Failed to Bind to Port [5 Ways]
The most common reason for Minecraft failed to bind to port error comes from the incorrect IP configuration. If you have entered something ......
Read more >Minecraft Server Error: Failed To Bind To Port - Apex Hosting
The failed to bind to Port Minecraft server error occurs when a server attempts to use a service port (i.e 25565) that is...
Read more >[Solution] "Failed to bind to port" - Support - Minecraft Forum
Failed to bind to port is an issue which is caused by the host operating system. Either because something is already running on...
Read more >How to Fix 'Failed to Bind to Port' Error on Minecraft? - Appuals
Solution 2: Changing the IP Configuration · We will need a text editor to edit the server files. · Navigate to this address...
Read more >5 Fixes for Minecraft Server Failed to Bind to Port
Minecraft's failure to bind to port is most likely due to incorrect IP settings. If another server uses the same port and IP...
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
Here is a simple implementation that allows any ip/port:
wow … i have to study now !
thank you so much again. I saw many things in closed ticket speaking about what i wan’t to do.