2

While Installing SSL Certificate on AWS, I renamed the old crt files (like a fool), and now I'm no longer able to access the AWS instance via SSH to fix the file names.

Is there a way to access my AWS instance's files other than SSH? Or, is there a way to continue using SSH to access the instance when the SSL certificates are down?

Originally when I was connecting after the change of file names, I got this prompt response from the server when SSH:

> ssh -vv -i tc.pem ubuntu@tc.com
OpenSSH_7.5p1, OpenSSL 1.0.2l  25 May 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "tc.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to tc.com [1.1.1.1] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file tc.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file tc.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
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
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to tc.com:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 1.1.1.1 port 22

At one point I did a reboot on the server and now, I'm getting this when I try to SSH in:

> ssh -i tc.pem ubuntu@tc.com
ssh: connect to host tc.com port 22: Connection timed out

If I could get into the server or access the files in any way to rename them, it would be an easy fix. Appreciate any help anybody can offer.

Rob
  • 897
  • 3
  • 8
  • 22

1 Answers1

1

This is fairly easy to do. Basically you will mount your EC2 instance's root volume (EBS volume) on another instancce, edit .ssh/authorized_keys and then reattach the volume back to your instance.

Here is an article that covers this step-by-step:

SSH Key Access Recovery on EC2 Instances

There are a number of similar articles on the Internet.

John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • That worked just perfectly. I was in the middle of following [this other page](https://aws.amazon.com/articles/how-to-recover-an-unreachable-linux-instance/) that has pretty much the same information as the one you provided. I did have to mount it a little differently because it's an ext4, but that is also covered [here](https://stackoverflow.com/questions/28792272/attaching-and-mounting-existing-ebs-volume-to-ec2-instance-filesystem-issue). Thanks for your help, John! – Rob Nov 10 '17 at 23:31