I can connect to the remote SFTP server fine through FileZilla, and have determined the remote server uses the following:
- diffie-hellman-group1-sha1
- ecdh-sha2-nistp521
- aes256-ctr
- ecdsa-sha2-nistp521
I am trying to connect to it using the NPM package ssh2-sftp-client here.
My code is the following:
let Client = require('ssh2-sftp-client');
async function main() {
try {
let sftp = new Client();
sftp.on('error', (err) => {
sftp.errorHandled = true;
console.log('custom error handler', err);
});
await sftp.connect({
host: 'server',
username: 'username',
password: 'password',
port: 60022,
readyTimeout: 20000,
debug: console.log,
algorithms: {
kex: [
"diffie-hellman-group1-sha1",
"ecdh-sha2-nistp521"
],
cipher: [
"aes256-ctr"
],
serverHostKey: [
"ssh-rsa",
"ecdsa-sha2-nistp521"
],
hmac: [
"hmac-sha2-256"
]
}
});
let result = await sftp.list(`/`);
console.log(result);
await sftp.end();
} catch (err) {
console.log('catch', err)
}
}
main();
process.on('uncaughtException', (err) => {
console.log('uncaught', err);
process.exit(0);
})
I keep getting the following error:
Handled Error: Timed out while waiting for handshake undefined
I have also tried with the NPM package: SSH2 here
No matter what kind of configuration I try, it always errors out. Does any one have any ideas?