我正在尝试使用Firebase函数将一个文件发送到webtrends服务器,但是我遇到了一个无法通过的问题。由于我使用Firebase函数,所以我的函数是从nodejs服务器上运行的。我正在使用这个npm包:https://www.npmjs.com/package/ssh2-sftp-client。
在在线阅读并解释调试日志之后,我理解了一个问题,即服务器使用了一个废弃的加密算法(ssh-dss)。我在这里读到https://www.openssh.com/legacy.html,ssh-dss是遗留的,因此不受ssh2支持。
我找到的大多数其他解决方案都告诉我要配置ssh配置,但在这种情况下,我无法访问遥控器,也无法配置它。
下面是我用来连接的代码:
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'],
},
});下面是调试日志:
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发布于 2018-09-07 11:23:54
配置选项中有一个错误。按照描述的在医生里使用这些设置,它可能会工作:
algorithms: {
serverHostKey: ['ssh-dss'], // serverHostKey, without the 's'
},发布于 2018-03-14 08:58:09
因此,如果您不能配置服务器,而ssh2-sftp客户端表示它们不支持ssh-dss,那么您唯一的选择是不使用ssh2-sftp-client,而是使用另一个支持ssh-dss的包。
做一个快速的Google搜索nodejs ftp client "ssh-dss",应该不难找到一个支持ssh-dss,例如yocto-sftp。
https://stackoverflow.com/questions/49153078
复制相似问题