I am trying to do some work on a remote server using ssh--and ssh is called on the local machine from node.js
A stripped down version of the script looks like this:
var execSync = require("child_process").execSync;
var command =
'ssh -qt [email protected] -- "sudo mv ./this.thing /to/here/;"';
execSync(command,callback);
function callback(error,stdout,stderr) {
if (error) {
console.log(stderr);
throw new Error(error,error.stack);
}
console.log(stdout);
}
I get the requiretty
error sudo: sorry, you must have a tty to run sudo
.
If I run ssh -qt [email protected] -- "sudo mv ./this.thing /to/here/;"
directly from the command line--in other words, directly from a tty--I get no error, and this.thing
moves /to/there/
just fine.
This is part of a deploy script where it really wouldn't be ideal to add !requiretty
to the sudoers file.
Is there anyway to get node.js to run a command in a tty?
node script.js
withstdio: "inherit"
andspawn
instead ofexec
leads tonull
for stdio on the spawned process--butprocess.stdin.isTTY
inscript.js
returnstrue
. Themv
command is run successfully on the other machine, though. – Devious