ssh_exchange_identification:连接由Git bash下的远程主机关闭

Mor*_*eze 46 git ssh

我在win7工作并使用sshd设置git服务器.我git --bare init myapp.git,正确克隆ssh://git@localhost/home/git/myapp.gitCywgin中.但是我需要再次使用Cygwin的配置git ,我想在Git Bash中使用 git clone .我跑步git clone ssh://git@localhost/home/git/myapp.git并获得以下信息

ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)

然后我ssh -vvv git@localhostGit Bash中运行并获得消息

debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /c/Users/MoreFreeze/.ssh/identity type -1
debug3: Not a RSA1 key file /c/Users/MoreFreeze/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace 
// above it repeats 24 times
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /c/Users/MoreFreeze/.ssh/id_rsa type 1
debug1: identity file /c/Users/MoreFreeze/.ssh/id_dsa type -1
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)

好像我的私钥有错误的格式?而且我发现私有密钥中只有25行没有BEGINEND.我很困惑为什么它说NOT RSA1键,我完全确保它是RSA 2键.

欢迎任何建议.顺便说一句,我已经在谷歌上阅读了关于这个问题的前三页.

Pac*_*nSV 51

我今天遇到了这个问题,我意识到我已连接到2个不同的网络(LAN和WLAN),我解决了它只是从我的以太网适配器断开电缆.我想问题是由于ssh密钥与我的无线适配器的MAC地址绑定而引起的.我希望这可以帮助你.

  • 对我来说,只需拔掉然后重新插入 LAN 电缆即可解决问题。 (3认同)
  • @akelec 不敢相信这有效,但它确实有效 (2认同)

Cor*_*ein 22

我今天遇到了这个问题,那是因为我尝试连接的服务器因处理而过载.因此,服务器可能内存不足或CPU缺乏.


Dav*_*wii 13

刚进入;

echo 'SSHD: ALL' >> /etc/hosts.allow
Run Code Online (Sandbox Code Playgroud)

它为我整理出来.

  • 我尝试这样做,我得到了一个许可被拒绝...我尝试使用sudo,它仍然说许可被拒绝......任何修复? (3认同)
  • 不要 chmod 777 该文件。这是对全球客人的访问。相反,正确修改它: `sudo -s "echo 'SSHD: ALL' >> /etc/hosts.allow"` (2认同)

pra*_*upd 12

ssh restartlinux中点击以下命令

prayag@prayag:~/backup/NoisyNeighbour$ service ssh restart 
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.75" (uid=1417676764 pid=5933 comm="stop ssh ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.76" (uid=1417676764 pid=5930 comm="start ssh ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Run Code Online (Sandbox Code Playgroud)

  • 重新启动有帮助的事实......令人担忧. (6认同)

小智 9

要解决问题,请在 上添加 Git 的主机名~/.ssh/config

Host github.com
 Hostname ssh.github.com
 Port 443
Run Code Online (Sandbox Code Playgroud)

就我而言,github!

  • 谢谢你的建议,它对我有用。我在使用VPN连接github时遇到了同样的问题,因为github在中国被屏蔽了。通过VPN我发现http是可以的,但是当我使用默认端口22和默认主机名github.com的ssh时,总是发生“kex_exchange_identification:连接被远程主机关闭”错误。 (2认同)

Cam*_*nho 7

确保您没有连接到任何类型的VPN.

  • @deborah-digges 实际上您需要确保您的 VPN 主机可以访问您的 git 存储库。如果是这样,你应该没问题。 (2认同)

小智 5

得到了相同的错误消息。关闭WiFi,然后重新打开对我来说很有效。


Vik*_*pta 5

我将 /etc/ssh/sshd_config 中的 ssh 端口和 MaxStartups 变量更改为后解决了这个问题,

port 2244
MaxStartups 100
Run Code Online (Sandbox Code Playgroud)

然后,重新启动服务

service sshd restart
Run Code Online (Sandbox Code Playgroud)

如果仍然不起作用,请重新启动系统。


asm*_*mud 5

删除/删除后rm ~/.ssh/known_hosts,我的问题得到了解决