博客 / Linux/ 解决 NppFTP 连接 Ubuntu 时 "diffie-hellman-group1-sha1" 算法缺失错误

解决 NppFTP 连接 Ubuntu 时 "diffie-hellman-group1-sha1" 算法缺失错误

解决 NppFTP 连接 Ubuntu 时 "diffie-hellman-group1-sha1" 算法缺失错误

问题描述

在使用 Notepad++ 的 NppFTP 插件,通过 SFTP 方式连接 Ubuntu 16.04.4 服务器时,连接失败并提示以下错误:

[SFTP] Connection failed : kex error : did not find one of algos diffie-hellman-group1-sha1 in list curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 for kex algos
Unable to connect

错误的核心信息是:服务器支持的密钥交换算法列表中不包含客户端请求的 diffie-hellman-group1-sha1 算法。

解决方案

此问题是由于 OpenSSH 服务器默认禁用了较旧、安全性较低的密钥交换算法(如 diffie-hellman-group1-sha1),而较旧版本的 NppFTP 客户端可能仍默认使用该算法。解决方法是在服务器的 SSH 配置中重新启用该算法。

步骤一:修改 SSH 服务器配置

  1. 通过 SSH 终端(如 Xshell, PuTTY)连接到你的 Ubuntu 服务器。
  2. 使用文本编辑器(如 vim 或 nano)打开 SSH 服务器配置文件:
sudo vi /etc/ssh/sshd_config
  1. 在文件末尾添加以下配置行,以重新启用 diffie-hellman-group1-sha1 算法并指定一组密码套件:
KexAlgorithms diffie-hellman-group1-sha1,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
Ciphers 3des-cbc,blowfish-cbc,aes128-cbc,aes128-ctr,aes256-ctr

说明: 添加 KexAlgorithms 是为了将 diffie-hellman-group1-sha1 加入服务器支持的算法列表。添加 Ciphers 是为了确保兼容性,避免因密码套件问题导致后续连接失败。

步骤二:重启 SSH 服务

保存并退出配置文件后,重启 SSH 服务以使更改生效:

sudo service ssh restart

注意: 在较新的 Ubuntu 系统(如 18.04 及以上)中,服务管理命令可能为 sudo systemctl restart ssh

步骤三:重新连接

完成上述步骤后,即可尝试通过 Notepad++ 的 NppFTP 插件重新连接服务器,问题应已解决。

补充说明与安全建议

1. 算法安全性: diffie-hellman-group1-sha1 被认为是较弱的算法,存在潜在的安全风险。此解决方案是临时性的兼容措施。

2. 根本解决方案: 更佳的做法是更新你的 NppFTP 插件或 Notepad++ 到最新版本。新版本客户端通常支持更现代的、服务器默认启用的安全算法(如 curve25519-sha256),从而无需修改服务器配置。

3. 查看 Ubuntu 版本: 如需确认系统版本,可使用以下命令:

cat /etc/issue
# 或使用更详细的命令
lsb_release -a

4. 配置回退: 如果你未来升级了客户端并成功连接,建议从 /etc/ssh/sshd_config 中移除添加的 KexAlgorithmsCiphers 行,并重启 SSH 服务,以恢复服务器默认的更严格安全设置。

发表评论

您的邮箱不会公开。必填项已用 * 标注。