Amazon EC2: How to restore ~/.ssh/authorized_keys file? -


i accidentally overwritten entries in .ssh/authorized_keys. no longer able connect ec2 instance using .pem file. tried generate new .pem file, hoping process add entries .ssh/authorized_keys, didn't. tried read documentation, confusing me. can give simplified explanation/instructions on appreciated.

if instance ebs-based, can following:

  1. get correct copy of authorized_keys file ready. off 1 of instances, or reconstruct whole cloth, or grab off snapshot, or use new pem file, or whatever.

  2. stop instance can't reach (do not terminate it). step unavoidable. if can't stop instance because it's running important, you're sol.

  3. detach root volume stopped instance. should /dev/sda1. sure give name can find in volume list.

  4. attach different instance @ mount point, /dev/sdp.

  5. mount volume tmpdir on instance. mkdir /tmp/myrootvol && mount /dev/xvdp /tmp/myrootvol. note device name vary based on version of linux (if you're using linux @ all). older versions use different nomenclature.

  6. at point, you've got filesystem, root volume, mounted @ /tmp/myrootvol. fix authorized_keys file, unmount device, , detach volume.

  7. reattach volume original instance @ /dev/sda1 or whatever device name attached at.

  8. start instance up.

there go. you'll have accessible ec2 instance. wow pain wasn't it?


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -