Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|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
add comment

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
share|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
add comment

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

share|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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.