In one node.js script, I am using openssh to execute dos command from one windows server to another remote windows server. The remote server has openssh server running and i have tested it in ssh shell,
ssh username@hostname
But this does not work when I try from node.js. Here is the code which i am using ,
var SSH = require('simple-ssh');
var command = 'dir /b' //or dir
ssh = new SSH({
host: 'XXX.XXX.XX.XXX',
user: 'username',
pass: 'password'
});
ssh.exec(command, {
out: function(stdout) {
console.log(stdout);
}
}).start();
ssh.on('error', function(err) {
console.log('In Start, something went wrong.');
console.log(err);
ssh.end();
});
Above script throws error,
In Start, something went wrong.
{ Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall: 'read',
level: 'client-socket' }
please note, this gives output when i put "ls" as command , along with same error message. Ultimately I want to execute one bat file with some input parameters on remote windows server. I am not getting idea of this error and how to handle this.
Thanks
from Nodejs OPENSSH - Error: read ECONNRESET at TCP.onStreamRead
No comments:
Post a Comment