hi I'm trying to run dokku commands using ssh2 in nodejs but it always show me this output
Client :: ready
STDOUT: ! sudo dokku is not a dokku command.
! See dokku help for a list of available commands.
Stream :: close :: code: 1, signal: undefined
here is my nodejs code:
please guide me what I'm doing wrong ?
var Client = require('ssh2').Client;
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');
conn.exec('dokku', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
conn.end();
}).on('data', function(data) {
console.log('STDOUT: ' + data);
}).stderr.on('data', function(data) {
console.log('STDERR: ' + data);
});
});
}).connect({host: 'xxx.xxx.xx.XX', port: 22, username: 'dokku', password: 'password', passphrase:'password', privateKey: require('fs').readFileSync('./id_rsa') });
The dokku user is bound to the dokku command via sshcommand. So if you ssh to it you can run dokku commands without prefixing it. So if you ssh [email protected] you'll get the output of running dokku inside the server.
What you'll want to do is make a user you can ssh in as, and run dokku commands from.
@joshmanders ok now working but what if i want to run other command apart from dokku ?
From the new user you created? Just execute new commands on that user.
ok a very very thanks for quick reply :100:
No problem.