node.js - 连接到 sftp.webtrends.com 时没有匹配的主机 key

标签 node.js firebase sftp google-cloud-functions ssh2-sftp

我正在尝试使用 Firebase Cloud Functions 将文件发送到 webtrends ftp 服务器,但遇到了无法解决的问题。由于我使用 Firebase Cloud Functions,我的函数是从 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

最佳答案

您的配置选项中有一个拼写错误。按照描述使用这些设置 in the docs它可能会起作用:

algorithms: {
  serverHostKey: ['ssh-dss'], // serverHostKey, without the 's'
},

关于node.js - 连接到 sftp.webtrends.com 时没有匹配的主机 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49153078/

相关文章:

javascript - 为什么将数据加载到 Meteor Collection 中需要这么长时间?

firebase - 当用户使用电子邮件和密码登录时,auth.provider 未设置为 'password'

iOS swift 2.3 : correct syntax for application restorationHandler?

javascript - 检索两个用户之间的聊天记录 Sequelize

node.js - 在 docker : Error opening Api. yaml 中使用 pm2 运行 Node.js/Swagger 应用程序

node.js - 如何在 Heroku/Node.js 上部署 Rserve

firebase - StreamBuilder的Firebase查询立即出现和消失

java - 如何使用 JSch 访问 FTP 服务器?

Azure 逻辑应用 SFTP 复制文件操作因某些 SAS URL 而中断

amazon-web-services - 连接到 AWS Transfer for SFTP