Forgot FreePBX Admin Password

I had to change my FreePBX admin password recently due to security reasons. Does anyone know how to reset this without having to re-install Asterisk and FreePBX?

Can you get to the root command prompt?

Yes.

I am new to Asterisk and FreePBX, what is the syntax to use at the CLI

(Hehe I did this before (along time ago) it still echos around some FreePBX distros)

from bash

mysql -D asterisk -u root -pmyrootpassword -e "UPDATE ampusers SET password_sha1=’echo -n imanidiotandforgotmypassword|sha1sum|cut -d ' ' -f 1’ WHERE username=‘admin’ "

1 Like

Dicko

Please stop. I about passed out laughing at your last two posts. :wink:

The better way is to use our unlock feature we have outlined here. http://wiki.freepbx.org/display/L1/amportal+commands

Better perhaps Tony, and at least official, but I challenge you to a speed test :wink:

Dicko your way is fine but can lead to someone doing something stupid with commands and breaking MySQL. I just gave the official way of how to get into your GUI without changing the password in MySQL.

Well, I must agree , if they lost their password, they are probably prone to stupidity. One could perhaps modify the one liner to an “insert into” to add a new user with unlimited access, this of course would be much easier to do if the system you have does not have a root mysql password, that would give one the benefit of a one second one liner, without being a risk otherwise :wink:

So my “better” solution:-

mysql -D asterisk -e “INSERT INTO ampusers (username,password_sha1,sections) VALUES (‘verysafeuser’,’echo -n 'easypassword'|sha1sum|cut -d ' ' -f 1’,’*’ )”

will work for those without a root password set in mysql, add the -p and -u as appropriate if you have a more secure system.

OK without having to know any mysql commands or passwords the FreePBX unlock tool works perfect.

Tony:

Ironically if one was working with a distro like FreePBX-4.211.64-9, neither method would need either knowledge of mysql commands nor passwords (you don’t set one for the mysql root user (perhaps you should) ), both methods require a “copy and paste” technique, but surely mine is just quicker and far less complicated, so I claim the “better” and
"more perfect" solution in this case especially with your distro :wink:

(maybe I’ll get coal for this one also . . .)

The one single problem with your method is that if we ever change the location or functionality of the users at the database level your ‘command’ will fail, while ours would still work. That is perhaps what we are getting at here.

Then I would have to rewrite my method , much as you would have to rewrite yours :wink:

Perhaps had you covered this [problem in the wiki, this thread never would have happened.

Dicko, it is in the wiki:

http://wiki.freepbx.org/display/L1/amportal+commands

Oops, mea culpa.

That is incorrect. The method that we have mentioned here several times unlocks through php sessions. It has nothing to do with passwords and does not care what the admin password is.

Dicko my first comment on this thread was a link to the wiki which you replied to. Have another drink on me.