gpt4 book ai didi

ssh2 node js sftp protocol Error Handshake failed(Ssh2节点js sftp协议错误握手失败)

转载 作者:bug小助手 更新时间:2023-10-24 19:15:22 26 4
gpt4 key购买 nike



Hello i have a little problem, i developped a script sftp client with node js that connect to an sftp server and grab some files, i tested it with my local server its working, but when i tried to use it with production server i received this error :

你好,我有一个小问题,我开发了一个带有节点js的脚本sftp客户端,它连接到sftp服务器并抓取一些文件,我用我的本地服务器测试了它的工作情况,但当我试图将它与生产服务器一起使用时,我收到了这个错误:




Error: Handshake failed: no matching key exchange algorithm




i already generated the rsa key using ssh-keygen

我已经使用ssh-keygen生成了rsa密钥。



here is the relevant part of the script :

以下是脚本的相关部分:



var Client = require('ssh2').Client;
var fs = require('fs');
var path = require('path');

var args = process.argv.slice(2);

var connSettings = {
host: args[0] || '127.0.0.1',
port: args[1] || 22,
username: args[2] || 'karim',
password: args[3] || 'karimos',
algorithms: {
hmac: ['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1', 'hmac-sha1-96']
}

};

更多回答
优秀答案推荐

I also had the same problem and solved it by adding the following:

我也遇到了同样的问题,并通过添加以下内容解决了它:



algorithms: {
kex: [
"diffie-hellman-group1-sha1",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha1"
],
cipher: [
"3des-cbc",
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm",
"[email protected]",
"aes256-gcm",
"[email protected]"
],
serverHostKey: [
"ssh-rsa",
"ecdsa-sha2-nistp256",
"ecdsa-sha2-nistp384",
"ecdsa-sha2-nistp521"
],
hmac: [
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1"
]
}


For myself, I added debug: console.log to my config object. This output more about the connection attempt.

对于我自己,我将DEBUG:sole.log添加到我的配置对象中。这条输出详细说明了连接尝试。


{
"port": 22,
"host": "test.test.com",
"user": "test",
"password": "******",
"debug": console.log
}


Handshake: (remote) KEX method: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1




Handshake: No matching key exchange algorithm



Based on this error I updated my config's algorithm:

基于这个错误,我更新了我的配置算法:


{
"port": 22,
"host": "test.test.com",
"user": "test",
"password": "******",
"algorithms": {
"kex": [
"diffie-hellman-group14-sha1","diffie-hellman-group-exchange-sha1"
]
}
}

After adding this algorithm the connection was successful on my machine

添加此算法后,我的计算机上的连接成功



You may edit your /etc/ssh/sshd configuration file, on your server, in order to allow the key authentication method :)

您可以在服务器上编辑/etc/ssh/sshd配置文件,以允许使用密钥身份验证方法:)



My first suggestion would be to upgrade the ssh server on the server you're connecting to so that a more secure configuration can be had. This is the best/most secure solution.

我的第一个建议是升级您要连接的服务器上的ssh服务器,以便可以进行更安全的配置。这是最好/最安全的解决方案。



If you cannot make changes on this server and you absolutely need to connect, then you can explicitly set the kex to a list of key exchange methods you want to support (valid algorithm names can be found in the ssh2-streams documentation). For example:

如果您无法在此服务器上进行更改,并且您绝对需要连接,那么您可以显式地将kex设置为您想要支持的密钥交换方法的列表(有效的算法名称可以在ssh2-Streams文档中找到)。例如:



algorithms: {
kex: [ ... ]
}


Have you tried changing your algorithms declaration to...?

您是否尝试过将算法声明更改为...?



algorithms: {
serverHostKey: [ 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1', 'hmac-sha1-96' ],
}

算法:{serverHostKey:[‘hmac-sha2-256’,‘hmac-sha2-512’,‘hmac-sha1’,‘hmac-sha1-96’],}



Added "diffie-hellman-group-exchange-sha1",
i've got comment error unknown DH group

添加了“Diffie-Hellman-Groups-Exchange-Sha1”,我收到了评论错误未知的DH组


"kex": [
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha1",
"diffie-hellman-group-exchange-sha1",
"diffie-hellman-group1-sha1"
],
"cipher": [
"3des-cbc",
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm",
"[email protected]",
"aes256-gcm",
"[email protected]"
],
"serverHostKey": [
"ssh-rsa",
"ecdsa-sha2-nistp256",
"ecdsa-sha2-nistp384",
"ecdsa-sha2-nistp521"
],
"hmac": [
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1"
]

Blockquote

区块报价


 "diffie-hellman-group-exchange-sha1",

更多回答

can you give me some reference, but i have used filezilla to connect to the server and its worked, also i tried without the algorithms: { hmac: ['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1', 'hmac-sha1-96'] } and its didn't worked

你能给我一些参考吗,但我已经用Filezilla连接到服务器上,它工作了,我也尝试了没有算法:{hmac:[‘hmac-sha2-256’,‘hmac-sha2-512’,‘hmac-sha1’,‘hmac-sha1-96’]},它不工作

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com