I'm trying to connect to a server using a private key generated through cPanel and stored on my local machine, but I am getting the "Connection closed by remote host". Any ideas?

XXXXX-computer-2:~ XXXX$ ssh -v -i /path/to/private/key xxx@xxx.com
OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to xxx.com XX.XX.XX.XX] port 22.
debug1: Connection established.
debug1: identity file /path/to/private/key type -1
ssh_exchange_identification: Connection closed by remote host
link|improve this question
2  
You can increase the amount of *v*s up to 3. Try using -vvv to get more verbosity. – geek Apr 21 '10 at 10:23
feedback

migrated from stackoverflow.com Jan 25 '10 at 23:46

This question came from our site for professional and enthusiast programmers.

4 Answers

Other issue to check is if your /etc/hosts.allow /etc/hosts.deny files are rejecting the ssh connections from your IP.

Using a more verbose connection command will give you more detail and a more exact reason of the message.

Have tried this in my LAN, here is a sample log from a connection denied for this reason:

% ssh -v 192.168.0.13
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.0.13 [192.168.0.13] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/identity type -1
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: loaded 3 keys
ssh_exchange_identification: Connection closed by remote host
link|improve this answer
"Connection established" above says you're probably wrong. – haimg Oct 15 '11 at 23:14
1  
"Connection established" means that one host can connect to another not that the ssh session will be allowed, updated the answer with a log from small test at home. – jhcaiced Oct 15 '11 at 23:38
feedback

Most roads seem to lead to exhausting the total amount of permitted connections.

It looks what this gentleman is saying is correct : http://www.raditha.com/blog/archives/000604.html

But,

You could try this: http://archive.netbsd.se/?ml=openssh-unix-dev&a=2007-10&t=5430083

Or this: http://edoceo.com/notabene/ssh-exchange-identification

Or this: http://cakebaker.wordpress.com/2006/08/15/ssh_exchange_identification-connection-closed-by-remote-host/

link|improve this answer
feedback

You are using probably identity file for protocol version 1. Some ssh servers don't accept protocol 1 version by default.

link|improve this answer
This would result in a different message (specifically, "Protocol major versions differ", also preceded by "Remote protocol version" if in debug mode). Identity files are loaded early, but not actually used until the initial SSH handshake is over -- much later. – grawity Oct 15 '11 at 23:37
feedback

One of the possibility is that you have too many ssh (dead connection) already made in the server, it may due to inappropriate logout from the ssh.

Try to ps -ef | grep ssh on that server. See if there are lots of ssh established already. If you can't find anyway to go inside the server apart from ssh. One of the bad way is to reboot the server again. It should work fine :p

link|improve this answer
feedback

Your Answer

 
or
required, but never shown