You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
heimdall/remoteExec.js

27 lines
764 B
JavaScript

const nodeSsh = require('node-ssh');
const ssh = new nodeSsh();
module.exports = (command) => {
return new Promise(function(resolve, reject) {
ssh.connect({
host: config.ssh.host,
username: config.ssh.user,
privateKey: config.ssh.key
})
.then(function(){
ssh.execCommand('/usr/bin/sudo -- ' + command, {cwd: config.infrastructure})
.then(function(result) {
if(result.code === 0) {
resolve(result);
} else {
reject(result);
}
}, function(result) {
reject(result);
})
}, function(result) {
reject(result);
});
});
};