Table of Contents
Method 1: Reset Administrator Password with GUI
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 to proceed with this tutorial.
1️⃣ Open your FreePBX web interface in a web browser. Once the page has loaded, press Ctrl + A on your keyboard to highlight everything on the page.
2️⃣ Locate the unique session ID on the screen and copy this string. It will look something like this: 4cgjtabeepdmacrj6rb0693so6.

3️⃣ Log into your FreePBX server via SSH as the root user, using a tool such as PuTTY on Windows, or Terminal on Mac then run the following command.
fwconsole unlock 4cgjtabeepdmacrj6rb0693so6
Session save path is undefined. This can cause undefined unlocks. Please set a 'session.save_path' in your php.ini file. It should match the same path that is set for the web portion of PHP. We have defaulted to [/var/lib/php/session]
Unlocking: 4cgjtabeepdmacrj6rb0693so6
Session Should be unlocked now
4️⃣ In your web browser, refresh the login page and you will be automatically logged in.
5️⃣ Visit Admin -> Administrators and select your user on the right side of the page. At this point, you can reset your password.

If you are using FreePBX 13 or earlier and the above gives you a ‘command not found’ error message, use the depreciated amportal command:
amportal a u 4cgjtabeepdmacrj6rb0693so6
Fetching FreePBX settings with gen_amp_conf.php..
session unlocked!
Method 2: 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
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: