Below code works. It returns the username. But it does not close the SSH session. I have to manually stop it. I tried other Linux command. None of them resolve...
`var SSH = require('ssh2-promise');
var sshconfig = {
host: 'x.x.x.x'
username: 'yyyyy',
privateKey: '-----BEGIN RSA PRIVATE KEY-----'};``
var ssh= new SSH(sshconfig);
(async function(){
var data = await ssh.exec('whoami');
console.log(data); //ubuntu
})();`
Below code works. It returns the username. But it does not close the SSH session. I have to manually stop it. I tried other Linux command. None of them resolve...