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

Locked out of EC2 ubuntu instance because of /home perms

· 52CE 我爱测

I was showing my kids some basic things about directory permissions on an EC2 ubuntu instance, and did this $ sudo chmod 700 /home Then demonstrated that I could no longer cd to my home directory because permission was denied. Th…

问题原文

原帖链接 · Fixee · CC BY-SA 4.0

I was showing my kids some basic things about directory permissions on an EC2 ubuntu instance, and did this

$ sudo chmod 700 /home

Then demonstrated that I could no longer cd to my home directory because permission was denied.

Then I inadvertantly disconnected from the EC2 instance. Now I cannot log back in because the sshd on the ubuntu side cannot access my /home/ubuntu/.ssh/authorized_keys file. I've tried to think about workarounds, but I'm out of ideas.

I am prepared to delete and recreate the entire instance, but would much rather salvage this one if possible. Any ideas?!

已采纳解答

原帖链接 · Fixee · CC BY-SA 4.0

Following Tim's suggestion:

I clicked Launch Instance to create a new instance. I just took whatever the first AMI was listed (some Amazon version of Linux) and created it with defaults, using a keypair I had already on hand.

I then clicked on Volumes and detached the EBS volume from my hosed machine. This took about 30 secs. Then I selected Attach Volume and I attached it to the new instance as /dev/sdf. Then I sshed into the new instance.

In the new instance I typed

$ sudo mkdir /caribou
$ sudo mount /dev/sdf1 /caribou
$ cd /caribou
$ sudo chmod 755 home

That repaired the /home dir permissions.

I then went back to the EC2 console, detached the EBS volume from the Amazon instance and re-attached it to my original Ubuntu instance as /dev/sda1. Then I started the old instance and logged in, with everything fixed.

Took 30 mins including time to figure out all of the above. Thanks to Tim.

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

资料来源与适用范围

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

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

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