Closed btxtiger closed 2 years ago
Shorter test code, also not prompting for password. Passing the password with the config works fine.
let SSH2Promise = require('ssh2-promise');
const ssh2Config = {
host: 'shop.com',
username: 'admin',
// password: 'asdasd',
identity: '~/.ssh/ssh-shop-prod',
tryKeyboard: true,
};
let ssh = new SSH2Promise.SSH(ssh2Config);
ssh.on('keyboard-interactive', (name, instructions, instructionsLang, prompts, finish) => {
console.log('Connection :: keyboard-interactive');
finish(['my_password_on_remote_machine']);
})
.connect(ssh2Config)
.then((val) => {
console.log('ok');
})
.catch((err) => {
console.log('err', err);
});
The problem was caused by multiple factors regarding the target server:
1) The key authentication was not working properly due to invalid permissions of the home directory of the remote user. Login via password and running chmod 755 ~ && logout
resolved this problem.
2) The path of identity
in the provided ssh config must be an ABSOLUTE PATH, so either pass the absolute path or write some function to convert ~/
starting paths into absolute paths.
It's not working for me, it does not show any password prompt. Seems tryKeyboard is ignored at all. Any ideas?