Script to 'reset' da_admin & da_roundcube password?

webunity

Verified User
Joined
Sep 23, 2014
Messages
49
I have a newly started VPS with a pre-installed (latest) version of DirectAdmin. Is there a script in DirectAdmin to change/reset the passwords for admin, da_admin and da_roundcube users?

I see that there is a guide for changing the admin & da_admin passwords, but i was wondering if there is also a script for it?

So far, i found these locations on my box;
server admin password & da_admin password:
/usr/local/directadmin/scripts/setup.txt

For MySQL user 'da_admin', the password is in:
/usr/local/directadmin/scripts/setup.txt
/usr/local/directadmin/conf/mysql.conf

For MySQL user 'da_roundcube', the password is in:
/var/www/html/roundcubemail-1.3.7/config/config.inc.php
/var/www/html/roundcubemail-1.3.7/config/my.cnf

Did i miss anything?

Regards,
Gilles
 
Hello,

I did no see anything of the kind. To change admin's password in a console you can use `passwd` , it is a standard NIX command. Or use Directadmin interface.

To change password in SQL for da_admin you can use mysql console or phpMyAdmin, and write your password to /usr/local/directadmin/conf/mysql.conf

I don't see any reason to change a da_roundcube password for a newly installed server. But you can remove
/var/www/html/roundcubemail-1.3.7/ and install roundcube once again, it should generate new password. Or follow the same recommendations as for the user da_admin, but do not write your password to /usr/local/directadmin/conf/mysql.conf, but update those files config/config.inc.php, config/my.cnf instead.
 
If anyone still want to change roundcube password longer and secured one. You should edit 3 things (include bash script command line because you requested scripting):

1) Change da_roundcube admin password through SQL eg with script:

Bash:
YOUR_NEW_PASSWORD="VPmoRwx_o?CU9ra+(,aX.%<mAcK}2vUv2X{],hXkZN<zu3L(a,oXR8]+"
mysql -e "ALTER USER 'da_roundcube'@'localhost' IDENTIFIED BY '${YOUR_NEW_PASSWORD}'; FLUSH PRIVILEGES;"

2) Edit /var/www/html/roundcube/config/config.inc.php and update your password

Code:
$config['db_dsnw'] = 'mysql://da_roundcube:$YOURNEWPASSWORD@localhost/da_roundcube';

OR automated with script:

Bash:
replace_rc_authconf="\$config['db_dsnw'] = 'mysql:\/\/da_roundcube:${YOUR_NEW_PASSWORD}@localhost\/da_roundcube';"
sed -i "s/\$config\[.db_dsnw.\]\s*=.*/${replace_rc_authconf}/" /var/www/html/roundcube/config/config.inc.php

3) Update your my.cnf for da_roundcube at /var/www/html/roundcube/config/my.cnf

Code:
[client]
user=da_roundcube
password=$YOURNEWPASSWORD

OR automated with script:

Bash:
sed -i "/\[client\]/,/^\[/ s/user=.*/user=da_roundcube/" /var/www/html/roundcube/config/my.cnf
sed -i "/\[client\]/,/^\[/ s/password=.*/password=${YOUR_NEW_PASSWORD}/" /var/www/html/roundcube/config/my.cnf


Warning, don't use password that contains this character for roundcube: @ & and : it will not work (roundcube won't accept these characters in config).

Finally if you want to make sure that your password won't be erased by roundcube when doing ./build roundcube, do this:

Bash:
mkdir -p /usr/local/directadmin/custombuild/custom/roundcube
cp -p "/var/www/html/roundcube/config/config.inc.php" "/usr/local/directadmin/custombuild/custom/roundcube/config.inc.php"

When you do ./build roundcube, your my.cnf also will be updated automatically with your custom password even if you change it manually. So, you don't have to touch that my.cnf anymore
 
Last edited:
Hello all,

The solution is already contained in the previous answer by maxi32. He states:

Finally if you want to make sure that your password won't be erased by roundcube when doing ./build roundcube, do this:

Whenever RoundCube is built by Custombuild, it always replaces the da_roundcube user's mysql password. So there's no need to do any work by yourself to achieve this, just do a Custombuild for RoundCube, and you're done ;) You may inspect the output of:

/usr/local/directadmin/custombuild/build roundcube

That should look like this:

Found MySQL version X.X
Granting access: GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,LOCK TABLES,INDEX,REFERENCES ON da_roundcube.* TO 'da_roundcube'@'localhost';
Setting password: SET PASSWORD FOR 'da_roundcube'@'localhost' = PASSWORD('<fancy_new_random_password>');
Editing roundcube configuration...
Roundcube 1.X.XX has been installed successfully.

This random new password is different every time, and is automatically updated in all relevant configuration files used by RoundCube ;)
 
Back
Top