ssh 连接报错:debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

本文详细介绍了在配置项目过程中遇到的SSH连接GitHub失败的问题及解决方法。通过调整/etc/ssh/ssh_config文件中的设置,成功解决了连接问题,适用于Windows环境下使用Git Bash的用户。

今天在笔记本上配置项目。
但ssh key怎么也连不上

使用ssh -vT git@git.github.com
找到了错误debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

网上有两种解决方案

  1. 修改MTU,改小数值,尝试后无效
  2. 偶然发现一个帖子,修改/etc/ssh/ssh_config试验有效

解决办法
按如下内容,修改/etc/ssh/ssh_config

#       $OpenBSD: ssh_config,v 1.34 2019/02/04 02:39:42 dtucker Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
#   ForwardAgent no
#   ForwardX11 no
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
   MACs hmac-md5,hmac-sha1,umac-64@openssh.com
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
# Added by git-extra
Ciphers +aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
#Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
HostKeyAlgorithms ssh-rsa,ssh-dss

windows上用git,需要装git bash,在git bash内,有虚拟环境,/etc/ssh/ssh_config 文件路径不变。

xyc@xyc-virtual-machine:~$ ssh -Tv -p 29418 xiayuchen@gerrit-ce.tp-link.com OpenSSH_7.6p1 Ubuntu-4ubuntu0.7, OpenSSL 1.0.2n 7 Dec 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to gerrit-ce.tp-link.com [10.176.69.107] port 29418. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 debug1: Remote protocol version 2.0, remote software version GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0) debug1: no match: GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0) debug1: Authenticating to gerrit-ce.tp-link.com:29418 as 'xiayuchen' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: ecdh-sha2-nistp256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:94zokm8g9MOxm56wKUpvlohudHHs+WfWn+YsZ1pWeDM debug1: Host '[gerrit-ce.tp-link.com]:29418' is known and matches the ECDSA host key. debug1: Found key in /home/xyc/.ssh/known_hosts:1 debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/xyc/.ssh/id_rsa debug1: Trying private key: /home/xyc/.ssh/id_dsa debug1: Trying private key: /home/xyc/.ssh/id_ecdsa debug1: Trying private key: /home/xyc/.ssh/id_ed25519 debug1: No more authentication methods to try. xiayuchen@gerrit-ce.tp-link.com: Permission denied (publickey). |这是什么问题
08-13
Active code page: 65001 (base) PS C:\Users\admin> ssh -v -F C:\Users\admin\.ssh\config 192.168.133.128 OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 debug1: Reading configuration data C:\\Users\\admin\\.ssh\\config debug1: C:\\Users\\admin\\.ssh\\config line 1: Applying options for 192.168.133.128 debug1: Connecting to 192.168.133.128 [192.168.133.128] port 22. debug1: Connection established. debug1: identity file C:\\Users\\admin/.ssh/vscode_key type 3 debug1: identity file C:\\Users\\admin/.ssh/vscode_key-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_for_Windows_9.5 debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.13 debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.13 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 192.168.133.128:22 as 'wxy' debug1: load_hostkeys: fopen C:\\Users\\admin/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ssh-ed25519 SHA256:ARKgKOcUrCYKBXslAKK7GUtnB+cxhaWc17VF3/ZPqv4 debug1: load_hostkeys: fopen C:\\Users\\admin/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory debug1: hostkeys_find_by_key_cb: found matching key in C:\\Users\\admin/.ssh/known_hosts:1 debug1: hostkeys_find_by_key_cb: found matching key in C:\\Users\\admin/.ssh/known_hosts:5 debug1: hostkeys_find_by_key_hostfile: hostkeys file C:\\Users\\admin/.ssh/known_hosts2 does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file __PROGRAMDATA__\\ssh/ssh_known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file __PROGRAMDATA__\\ssh/ssh_known_hosts2 does not exist The authenticity of host '192.168.133.128 (192.168.133.128)' can't be established. ED25519 key fingerprint is SHA256:ARKgKOcUrCYKBXslAKK7GUtnB+cxhaWc17VF3/ZPqv4. This host key is known by the following other names/addresses: C:\Users\admin/.ssh/known_hosts:1: 192.168.18.131 C:\Users\admin/.ssh/known_hosts:5: [hashed name] Are you sure you want to continue connecting (yes/no/[fingerprint])? Host key verification failed.
最新发布
10-12
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值