node exec child_process ssh command password
const { exec } = require('child_process');
const sshCommand = 'ssh user@hostname command';
const password = 'your_password';
const fullCommand = `${sshCommand}<<<${password}`;
const child = exec(fullCommand, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Error: ${stderr}`);
return;
}
console.log(`Output: ${stdout}`);
});
child.stdin.end();