Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

I am trying to ssh into my ubuntu server (which I have done many times before) and I get the error:

ssh_exchange_identification: Connection closed by remote host

ssh -vvv shows the following:

jimsmith:etc jimsmith$ ssh -vvv galleryserver
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/jimsmith/.ssh/config
debug1: Applying options for galleryserver
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /Users/richardelliot/.ssh/galleryserverkey.pem.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /Users/richardelliot/.ssh/galleryserverkey.pem type -1
debug1: identity file /Users/richardelliot/.ssh/galleryserverkey.pem-cert type -1
ssh_exchange_identification: Connection closed by remote host

Can anybody help?

--UPDATE---

I just found out that the server has been upgraded. So basically its a new machine but it using the same key and ip-address

share|improve this question

marked as duplicate by Hauke Laging, mdpc, Jenny D, Ward, Tim Brigham Jun 4 '13 at 20:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Corrupted key most likely. Try regenerating them. –  Nathan C Jun 4 '13 at 14:22
    
@NathanC Not at all corrupted. Wrong key format. –  Hauke Laging Jun 4 '13 at 14:34
    
The question is: What have you done since the last successful login? SSH key files don't change their key format on their own. Do you claim to have logged in successfully from that system as that user with the same application and not touched ~/.ssh? –  Hauke Laging Jun 4 '13 at 14:36
    
Please view my update above. –  Bob Flemming Jun 4 '13 at 14:37
1  
You have a client problem not a server problem thus your update doesn't help. –  Hauke Laging Jun 4 '13 at 14:39

2 Answers 2

It seems like you are not using a proper SSH private key as is alluded to by

debug3: Not a RSA1 key file /Users/richardelliot/.ssh/galleryserverkey.pem.

SSH keys usually are usually not .pem files - that is usually reserved for x509 certificates. Check your ssh keys in ~/.ssh; usually you have something like "id_dsa" (private key) and "id_dsa.pub" (public key). If using RSA then these files are id_rsa and id_rsa.pub instead. Make sure your SSH configuration, ~/.ssh/config, for that host points to the proper SSH keys.

If these files are not present you can generated them with

ssh-keygen -t dsa

then give your private key a passphrase and use something like keychain to manage your keys. You would then copy the local workstation public key, ~/.ssh/id_dsa.pub and merge it into ~/.ssh/authorized_keys on the remote server - creating that file if required. Ensure the permissions and server configurations is correct.

share|improve this answer
    
ssh-keygen can convert SSH keys into other formats. –  Hauke Laging Jun 4 '13 at 14:34
    
Please view my update above. –  Bob Flemming Jun 4 '13 at 14:36
    
SSH v2 RSA keys are PEM encoded. They are a standard RSA key the are exactly the same thing as what you get when you use OpenSSL genrsa. See: serverfault.com/questions/358239/… –  Zoredache Jun 4 '13 at 16:40

Ok I figured out what the problem was.

A module called deny hosts was preventing my IP from connecting.

I managed to connect from another IP address and then I added my IP address to the /etc/hosts.allow file.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.