-2

Some permissions are broken on my server, and I have lost the ability to use sudo. So I need to do su and change the permissions, but when I do su, I am asked for a password. I never set a password for root user... Where can I find the password?

j_d
  • 2,818
  • 9
  • 50
  • 91

2 Answers2

2

Most of the AMI's do not use passwords on their root user that I've noticed.

Your best bet would be to detach your EBS file system and mount it on another instance so that you can go in and fix the authorized_keys files or /etc/sudoers or whatever is appropriate to resolve your problem. Once it is fixed, you can unmount and detach it, then reattach it to your old instance so that it mounts as / again.

See this answer for info how to get access to your filesystem to fix things:

Add Keypair to existing EC2 instance

Community
  • 1
  • 1
Shadowfen
  • 459
  • 4
  • 11
0

Check /etc/passwd. The second colon-delimited field is the password.

However, the password is likely to be encrypted (represented as an x), meaning it will be in /etc/shadow as an encrypted value and you will need permissions to view it. Permissions are designed to prevent exactly what you want to do (i.e. escalate privilege), but those are the locations where you'd find that information on your instance.

Rome_Leader
  • 2,518
  • 9
  • 42
  • 73
  • Amongst other things, it has this line: `root:x:0:0:root:/root:/bin/bash`... What does this mean – j_d Jul 11 '16 at 11:23
  • Right, so as I said, the 'x' means the password is encrypted, and its encrypted version will be in the `/etc/shadow` file. You may be able to read its contents directly, but all you'll get is an encrypted version of the password. Not sure what more can be done. – Rome_Leader Jul 11 '16 at 11:24