Nodejs OPENSSH - Error: read ECONNRESET at TCP.onStreamRead

68
April 24, 2019, at 10:20 PM

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

READ ALSO
Puppeteer: Open a page, get the data, go back to the previous page, enter a new page to get data

Puppeteer: Open a page, get the data, go back to the previous page, enter a new page to get data

Getting data from 1 page is simple, but how to go back after getting data from first page, enter a new page, get data from that pageetc

48
Nodemon and babel-node restart multiple times

Nodemon and babel-node restart multiple times

I'm using nodemon with babel-node in development environmentI'm working on Windows 7 and every time I change my code, nodemon restart multiple times

46
Why is my Promise returning undefined in main.js from a module export?

Why is my Promise returning undefined in main.js from a module export?

Trying to learn how to work with Promises and AsyncI can send an object to a module but for some reason I continue to get an undefined when processing the return

26
Stop a process by port from javascript

Stop a process by port from javascript

I'm using jest to write some tests for a nodejs application

21