I want my nodejs app to execute a line of command and exit. The command is used for creating a remote port forwarding on a remote machine.
const exec = require("child_process").exec;
let script = "ssh -i cert.pem ubuntu@ec2 -R 9000:localhost:22 -S /tmp/.ssh-ec2 -M -fN ssh-ec2";
exec(script, (error, stdout, stderr) => {
console.debug(stdout);
});
node test.js
It hangs there; but if I run pure command in terminal.
ssh -i cert.pem ubuntu@ec2 -R 9000:localhost:22 -S /tmp/.ssh-ec2 -M -fN ssh-ec2
It exits.
What do I miss?