Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to find out if the shell Ubuntu root password is a certain word?

I deliver an image with a full Ubuntu installation to my customers, that has a certain root password.

I would like to add a check if the server is secure now, so I would like to try out the known standard password and if it is still the standard it should give out a warning that the rootpassword must be changed.

I don't want to brute force the server, I already know the standard-password and just want to check, if the new admin has changed the standard root-password, that was set in the Image that was used to copy the server.

I thought of something like

exec('ssh root@localhost --password=my_known_standard_pass')

Or maybe I could somehow create a shell script, that logs in with the sshkey stored somewhere that tries out the login and returns the success or not.

share|improve this question

migrated from May 3 '13 at 16:56

This question came from our site for professional and enthusiast programmers.

So you're asking how to brute-force a root shell via PHP? – Michael May 3 '13 at 12:36
You should enforce using secure passwords using administrative methods – hek2mgl May 3 '13 at 12:37
I clarified my question: I cannot force a change cause the server is a direct copy of another image – rubo77 May 3 '13 at 12:40
Answer his question if you know how - if he wants to brute-force his own server, so be it! – Jimbo May 3 '13 at 12:47
Though your intentions are not for bad, this is exactly the type of program hackers are looking for. It's executing shell commands -and one little mistake -and BAM I've got root access to the machine. I'm just saying, you really need to be careful. – Mike Perrenoud May 3 '13 at 12:55
up vote 2 down vote accepted

Since you're distributing an image, you know not only the root password, but also its encryption. You could implement a check in some startup file whether the encrypted password is still the original one.

share|improve this answer
ok, where do I find the encrypted password? – rubo77 May 3 '13 at 13:47
probably in /etc/shadow – Uwe May 3 '13 at 13:49
essentially, something like if grep -q '^root:eSdvXa\$oq\.Wzzxw1:' /etc/shadow ; then ... should be sufficient. Remember to escape grep metacharacters. (untested) – Uwe May 3 '13 at 13:57

You could also create a script that is run on the 1st login and forces a password change.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.