N.B. There are dozens of reasons that can lead to this problem, such as incorrect permissions on your .pem file, an incorrect username such as ec2-user or ubuntu, a typo in your command, and so on.
In my case, if I am right, the problem was caused by running sudo chmod -R ./ in the wrong directory, namely my home folder.
The solution is to set the home folder permissions back.
- Stop the problematic instance.
- Create a new instance, then stop the new problem-free instance.
- Make sure the newly created instance is in the same Availability Zone, such as
us-west-2c. This can be set in the Network step under the Subnet menu. - Detach the EBS volume from the problematic instance and attach it to the new problem-free instance.
- Enter your instance ID and the mount point, which looks like
/dev/sda2. - Start the new instance and mount the second drive that you just attached.
[ubuntu ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvdf 202:80 0 100G 0 disk
xvda1 202:1 0 8G 0 disk /
[ubuntu ~]$ sudo mount /dev/xvdf /mnt
- Change directory to the mounted path and restore the permission of your home directory to
755.
[ubuntu ~]$ cd /mnt/home/
[ubuntu ~]$ chmod 755 yourusername
- Stop the new instance and detach the volume owned by the problematic instance.
- Reattach the just-detached volume to the original problematic instance.
