Table of Contents
If you forget your administrator login information for FreePBX, there is a simple way to log in and reset it. You will need your current root password (for SSH to Linux server) to proceed with this tutorial.
Reset Administrator Password from database
1️⃣ Assuming our new password is newpassword, type the following from Linux command prompt to create a encrypted password. We need it to update the password in the database instead of the cleartext one.
echo -n 'newpassword' | sha1sum | cut -d' ' -f1
[root@cs8 ~]# echo -n 'newpassword' | sha1sum | cut -d' ' -f1
f2c57870308dc87f432e5912d4de6f8e322721ba
2️⃣ fwconsole m This will connect you to the mysql database as the FreePBX user automatically based on the username and password for MySQL in /etc/freepbx.conf.
fwconsole m
[root@cs8 ~]# fwconsole m
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 128
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [asterisk]>
3️⃣ Get the list of users in the database. In our case, we need to change the password of the admin account.
select * from ampusers;
MariaDB [asterisk]> select * from ampusers;
+----------+------------------------------------------+---------------+----------------+----------+----------+-------+-----------+
| username | password_sha1 | extension_low | extension_high | deptname | sections | email | extension |
+----------+------------------------------------------+---------------+----------------+----------+----------+-------+-----------+
| admin | 3af3a6de22296db524f3e7c79816aaded2a3b727 | | | | * | | |
+----------+------------------------------------------+---------------+----------------+----------+----------+-------+-----------+
1 row in set (0.000 sec)
4️⃣ Now enter the following command from mysql command prompt mysql>. Don’t forget replacing the hashed password that you’ve created from step 1.
update ampusers set password_sha1 = 'e8c36c9b6fee0e438e15aa073349cf718ddd2f29' where username = 'admin' limit 1;
MariaDB [asterisk]> update ampusers set password_sha1 = 'f2c57870308dc87f432e5912d4de6f8e322721ba' where username = 'admin' limit 1;
Query OK, 1 row affected (0.001 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Now you should be able to log into the Admin GUI with username: admin, password: newpassword
Cannot login into the database
Additionally, if fwconsole m does not take you to the database. You can connect to the database manually with the login credentials from this file /etc/freepbx.conf.
[root@cs8 ~]# cat /etc/freepbx.conf
<?php
$amp_conf['AMPDBUSER'] = 'freepbxuser';
$amp_conf['AMPDBPASS'] = '629106146fc8d1a08371b9d81c24d920';
$amp_conf['AMPDBHOST'] = 'localhost';
$amp_conf['AMPDBPORT'] = '3306';
$amp_conf['AMPDBNAME'] = 'asterisk';
$amp_conf['AMPDBENGINE'] = 'mysql';
$amp_conf['datasource'] = ''; //for sqlite3
require_once('/var/www/html/admin/bootstrap.php');
?>
Replace AMPDBUSER with the value found in /etc/freepbx.conf or /etc/amportal.conf. When it asks for password, use the value of AMPDBPASS in the same files.
mysql -u freepbxuser -p 629106146fc8d1a08371b9d81c24d920
[root@cs8 ~]# mysql -u freepbxuser -p asterisk
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 197
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [asterisk]> select * from ampusers;
+----------+------------------------------------------+---------------+----------------+----------+----------+-------+-----------+
| username | password_sha1 | extension_low | extension_high | deptname | sections | email | extension |
+----------+------------------------------------------+---------------+----------------+----------+----------+-------+-----------+
| admin | f2c57870308dc87f432e5912d4de6f8e322721ba | | | | * | | |
+----------+------------------------------------------+---------------+----------------+----------+----------+-------+-----------+
1 row in set (0.000 sec)
MariaDB [asterisk]>
Not a reader? Watch this related video tutorial: