# Script to clear password on Mac

Apple devices are known for their extensive security and privacy features. Apple does not allow users to remove the login password from their Macs as it could potentially risk any personal or confidential data if the device gets stolen or lost.

However, you will be able to set an empty string as the login password on your Macs using Hexnode’s [Custom Script](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) feature. The user will be able to log in to the device by simply clicking the “Enter” key without entering any password.

 Disclaimer:The sample scripts provided below are adapted from third-party open-source sites.

 

### Clear password on your Mac

Script to clear password on a macOS device using dscl command

dscl . passwd /Users/<username> <old password> “” 

   1

  dscl . passwd /Users/<username> <old password> “” 

   

 

  

The above-mentioned script sets an empty string as the login password for your Macs using the `dscl` command. It is required that you specify the name of the user whose login password is being cleared and the current password in the script.

Another method to clear passwords on Mac is by using the `sysadminctl` command. The script in this case requires you to specify the name of the user whose password is to be cleared as well as the name and password of the administrator of the endpoint.

Script to clear password on a macOS device using sysadminctl command

sysadminctl -resetPasswordFor <username> -newPassword "" -adminUser <admin username> -adminPassword <admin password> 

   1

  sysadminctl -resetPasswordFor <username> -newPassword "" -adminUser <admin username> -adminPassword <admin password> 

   

 

  

 Notes:- You will not be able to clear the password on FileVault enabled devices.
- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.