ssh_exchange_identification: Connection closed by

2019-03-08 03:19发布

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.git in Cywgin correctly. But I need config git of Cygwin again, I want to git clone in Git Bash. I run git clone ssh://git@localhost/home/git/myapp.git and get following message

ssh_exchange_identification: Connection closed by remote host

then I run ssh -vvv git@localhost in Git Bash and get message

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 BEGIN and END. I'm confused why it said NOT RSA1 key, I totally ensure it is RSA 2 key.

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

标签: git ssh
16条回答
啃猪蹄的小仙女
2楼-- · 2019-03-08 03:49

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.

查看更多
Root(大扎)
3楼-- · 2019-03-08 03:52

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.

查看更多
Viruses.
4楼-- · 2019-03-08 03:52

Just enter;

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

It sorted it out for me.

查看更多
手持菜刀,她持情操
5楼-- · 2019-03-08 03:52

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

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.

查看更多
We Are One
6楼-- · 2019-03-08 03:53

Got the same error too when connecting to GitHub with ssh as I move from one workplace to another. according to my situation, it seems that dns servers of different networks may get various ip address of github and the known_hosts file not identify it when changes happened. So change dns or switch back original network may work.

查看更多
虎瘦雄心在
7楼-- · 2019-03-08 03:54

I solved it after changing the ssh port & MaxStartups variable in /etc/ssh/sshd_config to ,

port 2244
MaxStartups 100

Then, restart the service

service sshd restart

If still it does not work, restart you system.

查看更多
登录 后发表回答