Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Braiam said that Firefox stores the password data for login websites in ~/.mozilla/firefox/key3.db and ~/.mozilla/firefox/signons.sqlite files. These files can be read with some sqlite editor.

I try to query for my username and password of a website (e.g. from the Firefox's database. I can't do it through Firefox, because my Firefox GUI is not working, and I am fairly new to and also interested in learning using databases to do the job.

  1. what are the different roles of key3.db and signons.sqlite?
  2. I searched on the internet, and is it correct that I should use sqlite3 to open a database?

    $ sqlite3 key3.db 
    SQLite version 3.7.9 2011-11-01 00:52:41
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> .tables
    Error: file is encrypted or is not a database

    I guess the reason of failure is that, in Firefox, I set up a master keyword to access the passwords it stores. How should I proceed to query the password of a given website?

    Btw, my OS is Ubuntu, and if it helps, here is the file type of key3.db :

    $ file key3.db 
    key3.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
  3. What shall I read and learn in order to query the password from a given website name?

    Will reading help?

To garethTheRed:

I tried your command. Not return anything however. The output is abysmal:

$ sqlite3 signons.sqlite
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
moz_deleted_logins  moz_disabledHosts   moz_logins        
sqlite> select * from moz_logins;

Does Firefox encrypt passwords regardless of if there is a master key? If yes, can we decrypte them in command line (my firefox CLI may still work)?

Alternatively, is it possible that Chrome browser can read and import the passwords stored by Firefox?

share|improve this question
You didn't add a semi-colon to the end of the SQL command. It should be select * from moz_logins; (note the semicolon at the end). – garethTheRed Aug 10 '14 at 15:44
Thanks, garethTheRed. (1) The output is now abysmal. Is it because my master key has encrypted it? (2) The output is long for all websites. is there a command to select the one for sourceforge? – Tim Aug 10 '14 at 15:56
Yes it's encrypted by the key in key3.db. Except it's not abysmal; it's brilliant as it's securing all your logons ;-) – garethTheRed Aug 10 '14 at 15:59
But I need it to show to me, because my firefox is not working. I have my master key. – Tim Aug 10 '14 at 16:00
Copy the files to another profile or a different computer (backing everything you overwrite up first of course). Have you tried FF as a different user? If it works for another user, then your FF profile is corrupt. – garethTheRed Aug 10 '14 at 16:06

3 Answers 3

up vote 2 down vote accepted

Some guy seem to have glued all the necessary code together at:

See the related discussion in the mozilla fora.

share|improve this answer

Although file shows key3.db to be in Berleley DB 1.85 format, it isn't the case. It's in a Mozilla proprietary format. It is used to encrypt the usernames and passwords in signons.sqlite.

You can view the date in signons.sqlite (but not decypher the usernames and passwords) using sqlite3:

sqlite3 signons.sqlite
SQLite version 3.8.5 2014-06-04 14:06:34
Enter ".help" for usage hints.
sqlite> .tables
moz_deleted_logins  moz_disabledHosts   moz_logins        
sqlite> select * from moz_logins;
[more here]

To search for a specific website use a basic SQL query:

sqlite> select * FROM moz_logins WHERE hostname LIKE "%arch%";

Note that they search phrase is in double quotes. The % is a wildcard, therefore in the example above it looks for any text, followed by arch, followed by any text. This covers

share|improve this answer
Thanks. I tried your command. Not return anything however (updated in my post). – Tim Aug 10 '14 at 15:42

The file key3.db contains the key that is used to encrypt the passwords stored in signons.sqlite.

As it is in a custom format, a special program is needed to work with it, instead of using standard database commands.

There seems to be a tool for Windows to make use of the key3.db file, see the answer on this question on SO: What is the encryption key of key3.db database in firefox profile?

The answer of @StéphaneChazelas provides a python script that should work on Linux;
Latest version here:

share|improve this answer
Thanks. what are the roles of key3.db and signons.sqlite? (1) Is signons.sqlite the database that stores the username and passwords of website logins (e.g. (2) Do you mean that key3.db a database storing the master key I set in Firefox to access its stored passwords for website logins? There is only one master key, so why do we need a database to store one master key? – Tim Aug 10 '14 at 15:13
@Tim On 1, yes. On 2, yes too - but what is the master key? It can only be some kind of security be obscurity, because I can open my browser and look at the passwords without that key. That may be the reason it's not documented in detail :) – Volker Siegel Aug 10 '14 at 15:18
"What is the master key?" When you try to view the password of each website from Firefox Preferences, if you haven't set up the master key, you are free to view website login passwords, but if you have set up the master key, you have to provide it before you can view the website login passwords – Tim Aug 10 '14 at 15:24
Yes, makes sense, it will contain the master key if set. I was assuming there is also a key in use if no master key is set in firefox, but not sure. – Volker Siegel Aug 10 '14 at 15:30
Without the master key set, will the login passwords show themselves directly, when you query in sqlite3? – Tim Aug 10 '14 at 16:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.