@mrieglhofer Z.B. so. Aus Gründen der Lesbarkeit bevorzuge ich async/await über die .then-Beispiel aus der Doku
const node_ssh = require("node-ssh");
const ssh = new node_ssh();
const password = "xxxxx";
async function main() {
await ssh.connect({
host: "192.168.2.1",
username: "admin",
port: 22,
password,
algorithms: {
cipher: ["3des-cbc"]
},
tryKeyboard: true,
onKeyboardInteractive: (name, instructions, instructionsLang, prompts, finish) => {
if (prompts.length > 0 && prompts[0].prompt.toLowerCase().includes('password')) {
finish([password])
}
}
});
const result1 = await ssh.execCommand('befehl', { cwd: '/pfad/zum/workdir' });
log('STDOUT: ' + result1.stdout);
log('STDERR: ' + result1.stderr);
// Weitere Befehle...
}
main();