Difference between revisions of "Password Recovery"

From FusionPBX
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
Here some rough steps to change the password of the database. These are specific for sqlite, but can be modified for other databases. The password can only be changed and not recovered.
+
Here some rough steps to change the password of the database. The password can only be changed and not recovered.
  
* Install sqlite3 which can be be used to modify the database fusionpbx.db.
+
The database contains a table called v_users which contains the username, password and salt. The password is the md5 hash of the password and the salt.
* The database contains a table called v_users which contains the username, password and salt. The password is the md5 hash of the password and the salt
 
* The hashed password and the salt can be updated using the command, update v_users set password = 'hashed_md5result', salt = 'salt-used-in-md5' where username = 'superadmin'
 
* The hashed_md5result can be obtained for a given 'password' and 'salt' using the following php script:
 
  
  
#cat password.php
+
==Password Hash==
  <?php
+
Use the following commands to generate the password hash. Don't forget to provide your own salt and password.
$salt = "random-salt-goes-here";
+
 
$password = "put your password here";
+
  echo '<?php $salt = "random-salt-goes-here";$password = "put your password here"; echo md5($salt.$password)."\n"; ?>' > /tmp/test.php
echo md5($salt.$password);
+
 
  ?>
+
Run the php file from command line.
 +
php /tmp/test.php
 +
 
 +
==SQLite==
 +
Install sqlite3 which can be be used to modify the database fusionpbx.db. Then open the database with the following:
 +
  sqlite3 fusionpbx.db
 +
 
 +
==PostgreSQL==
 +
Connect to the PostgreSQL database. Once you are running psql you can use \l to list the databases and \c to connect to one of them. After running the SQL Query then use \q to quit.
 +
 
 +
su postgres
 +
psql
 +
\c fusionpbx
 +
 
 +
==Change the Password==
 +
The hashed password and the salt can be updated using the command,
 +
update v_users set password = 'replace-with-password-hash-from-php-script', salt = 'replace-with-your-random-salt' where username = 'superadmin';

Latest revision as of 16:46, 4 May 2013

Here some rough steps to change the password of the database. The password can only be changed and not recovered.

The database contains a table called v_users which contains the username, password and salt. The password is the md5 hash of the password and the salt.


Password Hash

Use the following commands to generate the password hash. Don't forget to provide your own salt and password.

echo '<?php $salt = "random-salt-goes-here";$password = "put your password here"; echo md5($salt.$password)."\n"; ?>' > /tmp/test.php

Run the php file from command line.

php /tmp/test.php

SQLite

Install sqlite3 which can be be used to modify the database fusionpbx.db. Then open the database with the following:

sqlite3 fusionpbx.db

PostgreSQL

Connect to the PostgreSQL database. Once you are running psql you can use \l to list the databases and \c to connect to one of them. After running the SQL Query then use \q to quit.

su postgres
psql
\c fusionpbx

Change the Password

The hashed password and the salt can be updated using the command,

update v_users set password = 'replace-with-password-hash-from-php-script', salt = 'replace-with-your-random-salt' where username = 'superadmin';