Reputation: 1235
I am developing an application using node.js(v8.1.4), express and angularjs. Node.js is installed in windows server 8 and I want to connect other windows servers using their respective credentials.
After connection is established, I want to execute commands on remote servers. But I do not know how to connect remote windows server or what package is available for windows connectivity.
For executing commands locally , I am using below code that is working fine,
var exec = require('child_process').exec;
var execcommand = 'dir';
var myproccess = exec(execcommand);
myproccess.stdout.on('data', function(data) {
console.log(data)
}
But I am not getting an idea how to connect remote windows with credentials and execute command.
Please help. I have been struggling with this for many days.
Thanks
Upvotes: 0
Views: 2839
Reputation: 73
For the poor souls who have to work with Windows versions older than 10 (those who don't have built-in ssh servers), you can give PsExec a try. Some servers seem to come pre-installed with it. Here's the general syntax:
psexec.exe \\<address> <command>
Upvotes: 0
Reputation: 66
If you have SSH installed on each of the remote machines, you can execute a command in those servers by,
ssh <remote server ip or hostname> <command to execute>
However, you will need to setup the ssh keys in both machines in order to connect without password.
Upvotes: 2