5

I've been using an EC2 server with LAMP for a few months now and all of a sudden I can't connect to it via ssh. I run the same command on Cygwin I've been running since I've started working with it, which is:

ssh -i ./Desktop/keys/teste.pem ubuntu@54.94.211.146 -v

At first I was getting this message on the debugger:

$ ssh -i Desktop/teste.pem -v ubuntu@54.94.211.146
OpenSSH_6.7p1, OpenSSL 1.0.1j 15 Oct 2014
debug1: Connecting to 54.94.211.146 [54.94.211.146] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file Desktop/teste.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file Desktop/teste.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7
ssh_exchange_identification: Connection closed by remote host

Then I tried reeboting the EC2 instance through the AWS dashboard. Now I get this:

$ ssh -i ./Desktop/keys/teste.pem ubuntu@54.94.211.146 -v
OpenSSH_6.7p1, OpenSSL 1.0.1j 15 Oct 2014
debug1: Connecting to 54.94.211.146 [54.94.211.146] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file ./Desktop/keys/teste.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file ./Desktop/keys/teste.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 54.94.211.146

I have absolutely no idea what happened. I neither remember doing anything unusual nor messing with the identity file, as the debugger suggests the problem is with the identification. I've already tried to ssh with a different machine and a backup of 'teste.pem', the errors are the same. I'm really at a loss.

Thanks in advance!

Edit: At @asimovwasright 's request, I ran the command without the id file and got this:

$ ssh -v ubuntu@54.94.211.146
OpenSSH_6.7p1, OpenSSL 1.0.1j 15 Oct 2014
debug1: Connecting to 54.94.211.146 [54.94.211.146] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /cygdrive/c/Users/Gabriel/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 54.94.211.146

Basically the same error as before, so I guess the identity file is not to blame.

Gabriel Rebello
  • 1,077
  • 1
  • 11
  • 17
  • key_load_public: No such file or directory - could this be referring to the key on the server, - could you confirm that the /etc/ssh/ssh_config is pointing to the correct key files? (if you can get access at all :-|) – asimovwasright Feb 27 '15 at 09:01
  • Also, might be wise to replace your actual IP with in future... – asimovwasright Feb 27 '15 at 09:02
  • Thanks for the tip, @asimovwasright. And unfortunately I think I have no access to the server other than ssh. I'm worried that I've just lost 4 months of work all of a sudden :/ – Gabriel Rebello Feb 27 '15 at 10:16
  • I have no experience with ec2's, but can you say what would happen if you tried to connect without key file, like - $ ssh ubuntu@54.94.211.146 -v – asimovwasright Feb 27 '15 at 10:50
  • @asimovwasright I've edited the question with the result! – Gabriel Rebello Feb 27 '15 at 15:11
  • I think that cygdrive/c/Users/Gabriel/.ssh is your local ssh files directory - not the server side, - could you locate this directory on your pc and update the question with the contents, I suspect the contents are either empty or the directory path has changed, leaving the cygwin with no identification for the ssh connection. Either of which can be fixed. – asimovwasright Feb 27 '15 at 15:35
  • or at least it can't write the known_hosts file. Possibly the path you are indicating for teste.pem is incorrect, since you used different paths in the first two outputs, 1) Desktop/teste.pem 2) ./Desktop/keys/teste.pem – asimovwasright Feb 27 '15 at 15:45
  • @GabrielRebello did you ever get this resolved? I'm having the same problem with my EC2 instance. – Petter Aug 18 '15 at 12:31
  • 1
    Never mind, my issue was that I used the incorrect username, thought it would be `ubuntu`, but I had (unknowingly) created an instance with Amazon Linux AMI instead, so the username was `ec2-user`. – Petter Aug 18 '15 at 13:06

0 Answers0