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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10127818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:26:03  来源:igfitidea点击:

ssh_exchange_identification: Connection closed by remote host under Git bash

gitssh

提问by MoreFreeze

I work at win7 and set up git server with sshd. I git --bare init myapp.git, and clone ssh://git@localhost/home/git/myapp.gitin Cywgincorrectly. But I need config git of Cygwinagain, I want to git clone in Git Bash. I run git clone ssh://git@localhost/home/git/myapp.gitand get following message

我在 win7 工作并使用 sshd 设置 git 服务器。I 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

then I run ssh -vvv git@localhostin Git Bashand get message

然后我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

it seems my private keys has wrong format? And I find that there are exactly 25 line in private keys without BEGINand END. I'm confused why it said NOT RSA1 key, I totally ensure it is RSA 2 key.

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

Any advises are welcome. btw, I have read first 3 pages on google about this problem.

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

回答by PachinSV

I had this problem today and I realize that I was connected to 2 differente networks (LAN and WLAN), I solved it just disconnecting the cable from my Ethernet adapter. I suppose that the problem is caused because the ssh key is tied with the MAC address of my wireless adapter. I hope this helps you.

我今天遇到了这个问题,我意识到我连接到了 2 个不同的网络(LAN 和 WLAN),我解决了这个问题,只是从我的以太网适配器上断开了电缆。我想问题是因为 ssh 密钥与我的无线适配器的 MAC 地址相关联。我希望这可以帮助你。

回答by Cory Klein

I just ran into this today and it was because the server I was trying to connect to was overloaded with processing. So it may be possible that the server is low on memory or CPU starved.

我今天刚遇到这个问题,这是因为我试图连接的服务器处理超载。因此,服务器可能内存不足或 CPU 不足。

回答by David Okwii

Just enter on the server side :

只需在服务器端输入:

echo 'SSHD: ALL' >> /etc/hosts.allow

It sorted it out for me.

它为我整理了它。

回答by prayagupd

Hit the following ssh restartcommand in linux

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")

回答by Campinho

Make sure you are not connect to any kind of VPN.

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

回答by Dan Sheffler

Got the same error message. Turning off WiFi and turning it back on again worked for me.

得到同样的错误信息。关闭 WiFi 并再次打开它对我有用。

回答by asmmahmud

After removing/deleting the rm ~/.ssh/known_hosts, my issue was fixed

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

回答by Kinjal Dixit

if hostname does not work, try IP address.

如果主机名不起作用,请尝试 IP 地址。

This is going on right now so I have to say. I try to ssh with my host name and it does not work

现在正在发生这种情况,所以我不得不说。我尝试使用我的主机名 ssh 但它不起作用

ssh [email protected]

this gives the error "ssh_exchange_identification: Connection closed by remote host"

这给出了错误“ssh_exchange_identification:连接被远程主机关闭”

this USED to work one hour back.

这用于工作一小时。

BUT, and here is the interesting part, the IP address works!

但是,这里是有趣的部分,IP 地址有效!

ssh [email protected]

(of course the actual IP address is different)

(当然实际IP地址不同)

Go figure!

去搞清楚!

回答by elin3t

Hi I fix this on one vps service, restarting it, other way is if you have a console from your service o any other way to run a command in your remote machine the only command you must run is restart the ssh daemon and enjoy!! :P

嗨,我在一个 vps 服务上修复了这个问题,重新启动它,另一种方法是,如果您的服务中有一个控制台或任何其他方式在远程计算机上运行命令,您必须运行的唯一命令是重新启动 ssh 守护进程并享受!:P

/etc/init.d/ssh restart

回答by Vlad Isajkin

Similar to Arun Sangal the problem lied in an in .ssh/config entry

与 Arun Sangal 类似,问题出在 .ssh/config 条目中

Host my.sshhost.com
  ProxyCommand ssh -q -W %h:%p myremotemachine.my.company.com

The remote machine was added to avoid with ssh for VPN connections and worked well. But for the vacation period I switched off the myremotemachine and run into the described problem.

添加了远程机器以避免使用 ssh 进行 VPN 连接并且运行良好。但是在假期期间,我关闭了 myremotemachine 并遇到了所描述的问题。