Change the Password in Mac OS X 10.7 Lion Without Knowing the Current Password

Sep 19, 2011 - 32 Comments

Change password of current user in Mac OS X Lion There are a few ways to reset a password in Mac OS X 10.7 but both of those methods require reboots. This approach is different, it lets you change the password of the user currently logged into Mac OS X Lion, without knowing the user password, and without a reboot:

  • Launch the Terminal, located in /Applications/Utilities/
  • Type ‘whoami’ at the command line to get the current users precise login name, which will look something like this:
  • $ whoami
    Will

  • Type the following command, replacing ‘username’ at the end with the exact current users login name that you retrieved from whoami:
  • dscl localhost -passwd /Search/Users/username

  • Enter the new password once, hit return, and confirm the new password again hitting return

The password is now changed.

No authentication is required, you simply enter the new password and confirm the changed password. This is much easier than the manual reset methods and it doesn’t require a reboot or any manipulation of user data in Mac OS X.

Remember that like anything else in the command line, capitalization matters, so if the username is reported back as “Will” that would be different than “will” – be sure to use the proper caps for the password to be changed.

This tip is undeniably useful for a wide variety of situations pertaining to system administration, troubleshooting, and theft recovery, but could also post a potential security risk. Regarding the security risk, it’s realistic to assume that if someone has a computer in their possession, little is safe unless the drive itself is encrypted.

This trick was included in a broader and more mischievous tip that we’ll stay away from, nonetheless thanks to Daniel for sending this in!

Update: Additional reports and comments are suggesting this is a bug in OS X Lion, if so we could expect a Security Update to Mac OS 10.7 in the near future that would remove the ability to run dscl without administrative authentication. We’ll keep you posted.

Related articles:

Posted by: William Pearson in Mac OS X, Tips & Tricks, Troubleshooting

32 Comments

» Comments RSS Feed

  1. eras3r says:

    This is a great tip but also kind of freaky that it’s so easy. Granted 99.9% of Mac users don’t know Terminal exists let alone how to use it, this just goes to show that using FileVault is an exceptionally good idea.

  2. Ari says:

    Would be nice to know what the “more mischievous” tip is – especially from an IT Administrator’s perspective.

  3. Peter says:

    That’s not a tip. It’s a bug.

  4. Anderson says:

    Assuming the “mischievous tip” is about cracking passwords, it’s still on your Facebook wall.

    I suspect a patch will be released by Apple so that sudo is required to use dscl, it would be a simple and immediate fix to any threat posed by this.

  5. McNab says:

    The real security risk here is that ANY app could activate this command and change your password because it doesn’t even ask for credentials! This would be a freakishly easy trojan to install on a victims machine, Apple HAS to patch this ASAP!

  6. Will says:

    Out of interest, as it’s a similar idea. Is there a command for Terminal that changes the user’s account name?

  7. Jim T says:

    This is a bug, not a feature. It freaks me out.

    I’m unfamiliar with the intricacies of this app, but is a simple quick stopgap fix for it:

    sudo chmod go-x /usr/bin/dscl

    on the command line? That’ll knock out execute permissions for anybody except root on it, effectively requiring authentication to run it.

    Is it that simple to patch? Or am I missing something bad that could come from doing this?

  8. M says:

    Where is this /Search directory? As far as I know, this directory never existed in a Unix system. So, this recipe doesn’t work as expected and we have nothing here.

  9. Paulo says:

    You’ve got to be kidding me… of course this is a bug!! Damn Lion… :-(

    • Polk says:

      Why does everyone think it’s a problem? On Windows you never needed to know current password to change to new one. Just right click on user under system manager and select Reset Password. Windows wont ask you for the current.

  10. maddler says:

    @M: it’s not actually a real directory but a logical path used by dsctl and of course you won’t find it on your filesystem.

    I’ve just checked and the bug (since allowing to change a password without any check IS a bug) is present on 10.7.1.

    Hope we’ll have this fixed soon.

  11. maddler says:

    @jim: yes, changing permissions could actually do the trick. But this would require at least a minimal shell knowledge and many users won’t go that forward. IMHO.

    An official fix is advised.

  12. MU says:

    dscl . -passwd /Users/
    NB: srch dir’s redundant.

    Another good reason not to use Lion as main OS!
    Long live SL!

  13. Wowzers says:

    The tool itself isn’t a bug, the bug is not to require sudo

    99% of the web doesn’t understand this.

  14. chiggsy says:

    @Wowzers, I can see a possible truth in your statement, yet, it is irrelevant. 99% of the web is right in this case, it needs to be fixed. Of course, since that LDAP hole is not fixed either, we might as well wait upon the convenience of the central planners.

  15. Alberto says:

    If it is so simple to change a password I wonder what is the meaning of security on Mac?……

  16. [...] fallo se ha descubierto en Lion. Hace años que un agujero de seguridad parecido a este dejaba a merced de cualquiera el [...]

  17. Tjb says:

    type this command in the terminal, it fixes the problem.

    sudo chmod 100 /usr/bin/dscl

  18. [...] a Comment We recently wrote about the dscl utility and how it allows a Mac OS X Lion user to change a password without knowing the existing password. The lack of required admin authentication has since been widely reported as a bug, and a small [...]

  19. Y says:

    it does not work anymore.

  20. Mr. X says:

    WOW thanks sooo much! didn’t think it would work!!

  21. T says:

    when I did tried it still asked for the old users password

  22. Rishi says:

    Thanks it saved my time..

  23. bagus says:

    its not working for 10.7.2
    its still askd for old passwd
    is there any other way?

  24. Cody says:

    i have tried to do this multiple times but it keeps asking for the old password which i do not have, i type in…
    whoami
    it comes up with user even though my username for my computer is Cody
    then i tried both of the following…
    dscl localhost -passwd /Search/Users/user
    And…
    dscl localhost -passwd /Search/Users/user
    after both it asks me for the new password but i am unable to type anything into the terminal, after i press return it says, permission denied, please enter old password
    thats where my problem lays, i don’t know it!
    what did i do wrong?

    • Cody says:

      whoops, the sentence after the And… was supposed to be…
      dscl localhost -passwd /Search/Users/Cody
      sorry for the mistake!

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Shared on Facebook

Shop at Amazon

Ad

OSXDaily on Facebook