大网数据广告活动
服务器运维问答

AWS EC2 root lockout

· 52CE 我爱测

Accidentally changed permission in home directly using command: sudo chown -R root:root . Logging into EC2 instance remotely no longer works. Changing users (with root privileges), or to root user does not work. ssh [email omitte…

问题原文

原帖链接 · SentAmessage · CC BY-SA 3.0

Accidentally changed permission in home directly using command:

sudo chown -R root:root .

Logging into EC2 instance remotely no longer works. Changing users (with root privileges), or to root user does not work.

ssh [email omitted] -i /home/.ssh/id_rsa

Remote root login was disabled as suggested by AWS when instance was created.

Any suggestions on how to login? Or is all hope lost?

已采纳解答

原帖链接 · KHobbits · CC BY-SA 3.0

Amazon doesn't grant you anyway to log into a VM via any virtual KVM or remote host console.

If you are unable to SSH in at all, which sounds like the case, one way you can recover an instance is by mounting the root partition on another host.

To do this you would:

  • Stop the running instance via the console
  • Detach the relevant EBS volume
  • Spin up a new temp VM
  • Attach the EBS volume to be recovered to the instance
  • Mount the EBS volume to a temp path (/mnt?)
  • Fix any filesystem issues (or simply recover the necessary needed data)
  • Terminate temp VM
  • Attach the newly fixed volume to the old instance or a new instance as required.

If the instance needs to stay online while you attempt the recovery, or want to do a practice run through before doing it to the live volume you can use a snapshot of the problem volume. Take a snapshot of the running volume, and restore that to a new volume and follow the steps above with that volume.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。