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

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -