3

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 [email protected]
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
1
  • 2
    You can increase the amount of vs up to 3. Try using -vvv to get more verbosity.
    – geek
    Apr 21, 2010 at 10:23

5 Answers 5

1

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

1

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
2
  • "Connection established" above says you're probably wrong.
    – haimg
    Oct 15, 2011 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, 2011 at 23:38
1

I have gotten this when there was a DOS attack on SSH. If there are too many connections being attempted some may fail with this error.

0

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/

0

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

1
  • 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. Oct 15, 2011 at 23:37

You must log in to answer this question.