赵容用习惯了FlashFXP,遇到几次sftp连接debian12系统提示“SSH错误: 协商密钥交换算法失败”,每次都要去搜索解决,这里记录下来方便直接在博客找,如果有遇到相同问题的朋友也可以参考。
错误信息如上图,我在某个商家的3台VPS都遇到这个问题,估计他们的debian12系统模板问题,不过解决也挺简单,通过修改ssh配置解决。
nano /etc/ssh/sshd_config
加入:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes128-ctr HostKeyAlgorithms ssh-ed25519,rsa-sha2-256,rsa-sha2-512,ssh-rsa
保存后重启ssh服务即可:
sudo systemctl restart sshd