我在通过 SSH 访问我的服务器时突然遇到问题:
ssh -v --@--
OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g-fips 1 Mar 2016
debug1: Reading configuration data /home/paul/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to -- [--] port 22.
debug1: Connection established.
debug1: identity file /home/paul/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/paul/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
debug1: Remote protocol version 1.99, remote software version OpenSSH_6.6.1p1
debug1: match: OpenSSH_6.6.1p1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to --:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-cbc MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: aes128-cbc MAC: hmac-sha1 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<7680<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
ssh_dispatch_run_fatal: Connection to -- port 22: DH GEX group out of range
我读过这个问题SSH:DH_GEX 组超出范围广泛地,但它似乎没有回答这个问题。我控制客户端和服务器,它们都使用常规 OpenSSH 和 Ubuntu Linux。没有第三方。错误似乎也有点不同,它没有抱怨比特大小。
答案1
看起来你正在运行更新OpenSSH 客户端(OpenSSH 7.2p2)针对较旧OpenSSH 服务器(OpenSSH 6.6.1p1)。在OpenSSH 7.1p2 发行说明,其中提到:
- ssh(1)、sshd(8):将 diffie-hellman-group-exchange 支持的最小模数大小增加到 2048 位。
从报告的错误信息来看,它似乎是你的客户拒绝_server 提供的 DH 组交换值。
因此,我想知道“突发问题”是否在您的客户端机器应用一些软件包/更新时开始发生。
根据这个安全交换站,描述了一个非常相似的问题,“解决方案”可能是A)修改/etc/ssh/moduli
服务器端的文件,使服务器不使用小于 2048 位的 DH 组,或者b)将服务器升级到 OpenSSH 7.1p2 或更高版本。
答案2
如果您想使用较新的 OpenSSH 连接到已弃用的服务器:
ssh -o KexAlgorithms=diffie-hellman-group14-sha1 -o HostKeyAlgorithms=+ssh-dss my.host.com
如果您想查看发生了什么,请添加 -v,如果仍然不起作用,请添加 -o HostKeyAlgorithms=ssh-dss:
ssh -v -o HostKeyAlgorithms=ssh-dss -o KexAlgorithms=diffie-hellman-group14-sha1 my.host.com
当然,您也可以编辑 /etc/ssh/ssh_config 或 ~/.ssh/ssh_config,并添加:
Host my.host.com *.myinsecure.net 192.168.1.* 192.168.2.*
HostKeyAlgorithms ssh-dss
KexAlgorithms diffie-hellman-group1-sha1
https://forum.ctwug.za.net/t/fyi-openssh-to-access-rbs-openssh-7/6069提到了对 Mikrotik Routerboards 的以下修复:
/ip ssh set strong-crypto=yes
(之所以在这里指出这一点,是因为在网络搜索中寻找类似的错误消息时也会出现这个答案。)
如果您想通过 Git 使用它而不编辑 ssh_config 或更新 SSH 服务器:
GIT_SSH="ssh -oHostKeyAlgorithms=+ssh-dss -oKexAlgorithms=diffie-hellman-group14-sha1" git clone ssh://user@host/path-to-repository