Pages

Monday 24 October 2011

Regaining access to an AWS (Amazon) Linux machine

Say you secured so much your AWS server you can only login with SSH keys there. And you have only one SSH key that can access that server. And you lost your SSH key or forgot the passphrase for it.

Are you damned to lose all that work you have poured into that machine? Probably not, if you have the luxury of some downtime.

AWS does not have any (easy) way to just change the SSH key that can access to a system.

So after 30 minutes of attempts this is how I managed to get access back to my machine.
  1. Create another machine (a copy or just a new one it doesn't matter) and start it up. Pay attention to authorize a new SSH key that works to access this machine.
  2. Shut down the original machine
  3. Detach the (root) disk volume
  4. Attach that volume to the running instance
  5. mount the root partition (running dmesg or fdisk -l will tell you what to mount)
  6. go to <mtpoint>/root/.ssh/
  7. vi authorized_keys and add there the public key of your new key
  8. shutdown this new machine
  9. detach the volume
  10. reattach it to the old instance
  11. restart the instance and ssh into it with the new key

Be happy.


Ps. I found here another method involving snapshots but I just couldn't make it work. For some reason the cloned machine was always empty.

14 comments:

  1. Very informative! Thanks for providing your information. Keep Share and update with us AWS Online Training Hyderabad

    ReplyDelete
  2. Amazing site, Distinguished input that I can handle. Im advancing and might apply to my present place of employment as a pet sitter, which is exceptionally pleasant, yet I have to extra grow.
    Budget Friendly Web Hosting

    ReplyDelete
  3. Uttar Pradesh Maadhyamik Shiksha Parishad every year conducts UP Board Exams for High School & Intermediate. UPMSP conducts assessments for UP Board 10th Class Exams. UPMSP 10th Model Paper 2021 This Year UPMSP has a turn around things very quickly. Candidates who are going to seem in UP Board Exams should be seeking out UP Board Model Papers 2021 for Class 10th Exam, Practice Papers for High School Intermediate Board Exams.

    ReplyDelete
  4. Bank of Baroda Net Banking facility which is very easy to access International banking facilities, Register with required as BOB retail user for corporate banking, Check the login facilities of BOB Internet banking and use the online system to pay the credit card bill and more services. bank of baroda net banking Bank of Baroda is a multinational Indian bank with the best online banking services which is known to be one of the top public sector banking services all across the world, and there are very few and simple browser requirements for Bank of Baroda Internet Banking (BOB Net Banking) usage, for that the retailer or corporate user needs to follow in order to login to the online net banking facility.

    ReplyDelete
  5. Genuinely when someone doesn’t understand after that its up to other visitors that they will help, so here it happens.|

    성인야설

    ReplyDelete
  6. Hello, I log on to your blog regularly. Your humorist style is awesome, keep up the good work!|

    스포츠마사지

    ReplyDelete
  7. I was very happy to locate this web-site. I wished to many thanks for your time for this fantastic read!! I most definitely appreciating every little of it and also I have you bookmarked to take a look at new stuff you blog post.

    출장마사지

    ReplyDelete