app.js:
const fs = require('fs')
const path = require('path')
const {NodeSSH} = require('node-ssh')
const ssh = new NodeSSH()
ssh.connect({
host: '192.168.0.2',
username: 'ubuntu',
password: '123456'
})
.then(function() {
ssh.execCommand('virsh list --all', {}).then(function(result) {
console.log(result);
return;
})
})
Return:
Id Name State
--------------------
But the command virsh list --all
works and return complete list when using ssh connect via command line. I also test another command in app.js like ls
or pwd
, and works normally.
Thanks for helping.
Replace your command with: