I am trying to use Firebase Cloud Functions to send a file to webtrends ftp server, but I have encountered a problem I can not get past. Since I use Firebase Cloud Functions my function is running from a nodejs server. I am using this npm package: https://www.npmjs.com/package/ssh2-sftp-client.
After reading online and interpreting the debug log I understand the problem to be that the server uses a deprecated cryptation algorithm (ssh-dss). I read here https://www.openssh.com/legacy.html that ssh-dss is legacy and therefore not supported by ssh2.
Most of the other solutions I have found tell me to configure the ssh config, but I do not have access to the remote in this case and can not configure it.
Here is the code I am using to connect:
const Client = require('ssh2-sftp-client');
const sftp = new Client();
sftp.connect({
host: 'sftp.webtrends.com',
port: '****', // omitted
username: '****', // omitted
password: '****', // omitted
algorithms: {
serverHostKeys: ['ssh-dss'],
},
});
And here is the debug log:
DEBUG: Local ident: 'SSH-2.0-ssh2js0.1.20'
DEBUG: Client: Trying sftp.webtrends.com on port **** ...
DEBUG: Client: Connected
DEBUG: Parser: IN_INIT
DEBUG: Parser: IN_GREETING
DEBUG: Parser: IN_HEADER
DEBUG: Remote ident: 'SSH-2.0-1.82_sshlib GlobalSCAPE'
DEBUG: Parser: IN_PACKET
DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXINIT
DEBUG: Comparing KEXINITs ...
DEBUG: (remote) KEX algorithms: diffie-hellman-group14-sha1,diffie-hellman-
group-exchange-sha1,diffie-hellman-group1-sha1
DEBUG: (local) KEX algorithms: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-
sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
DEBUG: (local) Host key formats: ssh-rsa,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
DEBUG: Outgoing: Writing KEXINIT
DEBUG: Parser: pktLen:484,padLen:11,remainLen:480
DEBUG: Outgoing: Writing DISCONNECT (KEY_EXCHANGE_FAILED)
DEBUG: KEX algorithm: diffie-hellman-group14-sha1
DEBUG: (remote) Host key formats: ssh-dss
DEBUG: No matching host key format