可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
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:
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.
回答3:
Just enter;
echo 'SSHD: ALL' >> /etc/hosts.allow
It sorted it out for me.
回答4:
Hit the following ssh restart
command in linux
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")
回答5:
Make sure you are not connect to any kind of VPN.
回答6:
if hostname does not work, try IP address.
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 root@host.example.net
this gives the error "ssh_exchange_identification: Connection closed by remote host"
this USED to work one hour back.
BUT, and here is the interesting part, the IP address works!
ssh root@192.168.0.100
(of course the actual IP address is different)
Go figure!
回答7:
Got the same error message. Turning off WiFi and turning it back on again worked for me.
回答8:
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
/etc/init.d/ssh restart
回答9:
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.
回答10:
We migrated our git host instance/servers this morning to a new data center and while being connected to both: VPN (from remote/home) or when in office network, I got the same error and was not able to connect to clone any GIT repo.
Cloning into 'some_repo_in_git_dev'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
This will help if you are connecting to some or all servers via a jump host server.
Earlier in my ~/.ssh/config file, my setting to connect were:
Host * !ssh.somejumphost.my.company.com
ProxyCommand ssh -q -W %h:%p ssh.somejumphost.my.company.com
What this means is, for any SSH based connection, it will connect to any * server via the given jump host server except/by ignoring "ssh.somejumphost.my.company.com" server (as we don't want to connect to a jump host via jump host server.
To FIX the issue, all I did was, change the config to ignore git server as well:
Host * !ssh.somejumphost.my.company.com !mycompany-git.server.com !OrMyCompany-some-other-git-instance.server.com
ProxyCommand ssh -q -W %h:%p ssh.somejumphost.my.company.com
So, now to connect to mycompany-git.server.com while doing git clone (git SSH url), I'm telling SSH not to use a jump host for those two extra git instances/servers.
回答11:
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.
回答12:
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.
回答13:
You can get "ssh_exchange_identification: Connection closed by remote host" if your sshd
service is not operational!
If you have access to the server check you have the sshd
service running with:
ps aux | grep ssh
and check it is listening on port 22:
netstat -plant | grep :22
more details here
回答14:
For me this was caused by a limit on the number of concurrent ssh sessions. I added the two params below to /etc/ssh/sshd_config and then things worked.
echo 'MaxSessions 2000' >> /etc/ssh/sshd_config
echo 'MaxStartups 2000' >> /etc/ssh/sshd_config
service ssh restart
回答15:
Simple server reboot solved the problem for me. Try hard reboot , if dont work after soft reboot.
回答16:
Please use Port 7999 and Try. it will work