我使用net-sftp gem连接sftp服务器,它使用curve 25519-sha 256算法。我的客户不支持这个算法。我已经阅读了问题部分,发现了很多关于它的讨论,尝试了一些方法,但我仍然不能让它工作。下面是我的代码
require 'net/sftp'
Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[:kex].unshift("[email protected]")
Net::SFTP.start('ip_address_of_site', 'password', { password: 'password', append_all_supported_algorithms: true, verify_host_key: :never, verbose: :debug}, verify_host_key: :never) do |sftp|
ssh.sftp.connect do |sftp|
puts sftp.inspect
end
end
我收到以下错误
net-ssh-6.1.0/lib/net/ssh/transport/algorithms.rb:407:in `negotiate': could not settle on kex algorithm (Net
::SSH::Exception)
Server kex preferences: curve25519-sha256,[email protected]
Client kex preferences: ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,d
iffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
当我使用任何Mac软件连接它时,它工作正常,所以我的密码没有问题。
1条答案
按热度按时间nkhmeac61#
经过多次尝试,我发现以下是解决方案。它可能会帮助别人做同样的事情。
在Gemfile中添加宝石
现在在你的脚本中添加以下行
这将使用该算法进行欺骗和连接。但这仍然适用于英特尔处理器,而不是Mac M1处理器。
在net-ssh lib中,我们可以找到以下代码:
这是加载这两个gem(x25519,ed25519),如果他们安装。这就是为什么安装和加载gem可以解决这个问题。