Resetting In Single User Mode
If you’re not able to start your computer and load OS X’s interface (or SSH into your system), then you’ll need to start up your computer in Single User Mode (hold Command + S while booting).
Next, perform the following steps in order to reset your password.
Mount your file system by typing the following command and pressing enter:
mount -uw /
Next, we’ll load the Open Directory services.
OS X 10.7 or higher
launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
OS X 10.6 or earlier
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
Next, we’ll reset the password by typing in the following command:
dscl . passwd /Users/<username>
You’ll be prompted to enter a new password; follow the on-screen prompts to complete the password reset.
Finally, restart the system by typing the following command: