When I logged in to my ubuntu instance using ssh and tried to do "su root or sudo su root" it prompted me for password. Actually when you do the setup you don't need to enter password for above command.
If such kind of issue occurs following would be best solution:
- Create Temporary instance (Image should be same)
- Stop the old instance
- Detach Volume disk from old instance.
- Attach that volume disk to new temporary instance.
- SSH in to your new temporary instance and execute "mkdir /olddisk".
6 Mount your old volume by executing "sudo mount /dev/xvda1 /olddisk".
- Go to your "/olddisk" directory you created and edit sudoer (/etc/sudoer) file or just type visudo.
- Replace "ubuntu ALL=(ALL) ALL" with "ubuntu ALL=(ALL) NOPASSWD:ALL".
- Detach old volume from temporary instance and attached to your old instance as a root. To do that make sure drive is /dev/sda1 which is reserved for root as mentioned here http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html.
- Start your old instance.
- You can remove your temporary instance and now it won't ask for password when you execute "su root or sudo su root" command.