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

32 lines
943 B
JavaScript

const nodeSsh = require('node-ssh');
const ssh = new nodeSsh();
module.exports = (command, config) => {
console.log('l6');
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) {
console.log('l17');
resolve(result);
} else {
console.log('l20');
reject(result);
}
}, function(result) {
console.log('l24');
reject(result);
})
}, function(result) {
console.log('l28');
reject(result);
});
});
};