cPanel – change email password without cPanel access – edit shadow file

I had issue with cPanel on which license was expired. So web interface wasn’t accessible. One client had situation and need to change email password urgently. Because cpanel wasn’t accessible, he was unable to do so. There is a trick. You can change mail password without accessing cpanel directly. You can modify shadow file and paste new password hash. cPanel stores email passwords in shadow file. Here is how you can do it.

First, you need to generate new password hash in SHA512 format. You can do it with python:

[root@machine ~]# python3 -c 'import crypt; print(crypt.crypt("mynewpassword", crypt.mksalt(crypt.METHOD_SHA512)))'

Then you need to locate shadow file for your user and edit it:

root@cpanel [~]# cd /home/test/etc/
root@cpanel [/home/test/etc/]#
root@cpanel [/home/test/etc/]# vi shadow

Here is original hash for our user. You should change it with hash generated in first step. Change part which is marked with bold:


so it looks like this:


That’s it, you should be able to login in webmail with new password, generated with python – frist step.

© 2021
Hosted by Hosterdam

About author