Sometimes, you don’t have access to a GUI but you got yer grubby little paws on a terminal. I’ve had several of these occasions and have had to reset email passwords for clients.

How do we do this? Pretty easy, guys:

First, let’s set the scene:

The domain is : zz9.co.za
Cpanel username is : zz9usr
Email account is : example@zz9.co.za

We want to reset the password for example@zz9.co.za from the command line

Step 1:

Log into the server in question and switch user to root.

Step 2:

Type in the following command:

openssl

You should see the following (or similar) prompt:

zz9usr@example [~]# openssl

OpenSSL>

Step 3

Type in:

passwd -1 "your_new_email_password"

Where “your_new_email_password” is replaced with the password of your choice:

OpenSSL> passwd -1 “ThisIsMyNewPassword”

$1$8K8Ou607$6glWjTx8ZuLU6F8pSyc8i1

OpenSSL> quit

PLEASE NOTE: The option in the command (-1) is not the lower case L in the alphabet(l), but it is the numeric one (1)


The above command will give you the MD5 encrypted format version of your password, write it down somewhere exactly as is.

Step 4

Change to the Cpanel account home folder,

Change to the etc folder within the Cpanel account home folder:

zz9usr@example [~]# cd /home/zz9/etc/zz9.co.za
zz9usr@example [/home/zz9/etc/zz9.co.za]# 

If you do a list within the current working folder, you’ll see a couple of files and among them will be:

passwd, passwd,v , quota, quota,v , shadow, shadow,v

Step 5

We’re working with the following files:

shadow

shadow,v

Let’s open it up with nano:

nano shadow

Look for the line containing the username that we are looking for, in this specific case it would be “example” and it would like similar to this:

example:$6$itlQRN/bGoiCB/n/$53X3P/wy.lsS6u4u7vporiAqKBnfsF8Zx8b6MXs6/oxM876znssdsD3d3XNygq3pPOFR57ryWHk63A7JJr2r61:16673::::::

The part between the first colon and the second colon would be the password that we want to update. Replace the string with the MD5 password string that you copied down earlier:

example: $1$8K8Ou607$6glWjTx8ZuLU6F8pSyc8i1 :16673::::::

Save and close the file.

Step 6

Open up the shadow,v file with your favourite editor, for this example we will use nano

nano shadow,v

Look for the entries that match the email account that you are modifying, in this case it is “example”:

.
.
1.4
log
@”Modified by /usr/local/cpanel/cpanel “
@
text
@example:$6$itlQRN/bGoiCB/n/$53X3P/wy.lsS6u4u7vporiAqKBnfsF8Zx8b6MXs6/oxM0inzns3lsDfHdXNygq3pPOFR57ryWHk63A7JJr2r61:16673::::::
@
.
.

Replace the above with the same details as per the shadow file:

.
1.4
log
@”Modified by /usr/local/cpanel/cpanel “
@
text
@example:$1$8K8Ou607$6glWjTx8ZuLU6F8pSyc8i1:16673::::::
@
.
.

Save the file, exit the file and you’re all done!

Log into the webmail portion and win.

If you get stuck, please let me know.

\