Search

M y    b r a i n    h u r t s  !                                           w e                 r e a l l y                 t h i n k                   w h a t                y o u             k n o w

14 April 2012

Linux: How to export Google Chrome passwords to CSV file

Update: A simpler method is described in this stackoverflow.com post How can I export chrome passwords?

Having spent some time googling for a way to export Chrome passwords to an external file to my surprise I could not find a straightforward solution that would work irregardless of the version of Chrome/Chromium. Finally, this page provided a hint to a solution which worked for me.

Older versions of Chrome/Chromium for Linux stored unencrypted passwords in an SQLite database under:

### Google Chrome:
    ~/.config/google-chrome/Default/Login Data

    ### Chromium:
    ~/.config/chromium/Default/Login Data

In newer versions of Chrome this file is still present, but the passwords are not there anymore - they are stored using the encrypted password storage provided by the system, either Gnome Keyring or KWallet, which means that simply dumping the tables will not work. On OSX the Chrome passwords are in the system keychain, and can be viewed from System Keychain

The method below relies on forcing Chrome to use a temporary profile folder in combination with unencrypted password storage. This approach will not affect your current Chrome profile in any way.

So, to export your passwords to a human readable text file:

  1. Connect to your Google Account in Chrome Settings so that your passwords are synched with the Google cloud storage. Make sure that you have ticked Passwords in Advanced Sync Settings.
  2. Wait for a while until the data is synched, and then close all the Chrome windows.
  3. Start Chrome using one of the two command lines below. Google Chrome has a green-red-yellow icon , while the Chromium icon is in shades of blue .
    ### Google Chrome
        google-chrome --user-data-dir=/tmp/chrome-tmp --password-store=basic
    
    ### Chromium
        chromium --user-data-dir=/tmp/chrome-tmp --password-store=basic
    
    This will launch Chrome with a custom profile folder without affecting your current profile.
  4. Setup Google Synching for the new temporary profile and wait until everything is synced from the cloud, i.e. your bookmarks appear, extensions show up, the theme is applied, etc. Verify that the passwords are restored from the Google cloud by looking under Settings → Personal Stuff → Manage Saved Passwords. If they do not appear, then wait a couple of minutes more. Note: the fastest way to get to the stored passwords page in settings is to type password in the Search box in the top right.
  5. Exit Chrome.
  6. Next, open a terminal and change to the newly created Chrome profile
    cd /tmp/chrome-tmp/Default
    
  7. Now, open the Login Data SQLite database using the sqlite3 command line utility and dump the logins table. For this to work, you need to have sqlite3 installed on your system.
    sqlite3 'Login Data'
    
  8. Next, at the SQLite prompt enter the commands below. For help on available commands type .help at the prompt.
    .mode csv               # other options are `html', `tabs', etc.
    .headers on
    .separator ","
    .output chrome_passwords.csv
    select * from logins;
    .exit
    

Now you should have a file named chrome_passwords.csv containing all your Chrome passwords. To open it with LibreOffice, type:

libreoffice --calc chrome_passwords.csv

8 comments :

  1. Just great.

    I've been searching for a solution 15 minutes and even tried to use a Windows tool with WINE - your solution took me exactly 1 minute and I've got my passwords back, even well formatted in an .csv file.

    Thank you very much.

    PS: I'm new to Linux and the Terminal but you managed to make it easy even for a n00b :-)

    ReplyDelete
  2. wow! thank you so much!

    ReplyDelete
  3. The downside of this solution is that you share all your passwords with Google...

    Does anyone know any other way to decode Google Chrome entries in KWallet/Gnome Keyring?

    ReplyDelete
  4. Just wanted to pop in 3 years after the original post date to mention that not only does this method still work, three years later, for Chrome version 45.0.2454.85, it also saved my a** big time, so thanks OP! :)

    Quick tip: After exiting Chrome, if you get an error in sqlite3 that says "error, database is locked" after running 'select * from logins;' it most likely means that Chrome is still running in the background.

    You can confirm/change this setting by unchecking a box that allows Chrome to run in the background. The checkbox is located near the very bottom of the page of Chrome's advanced settings.

    Cheers! :)

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Now to be able to import them to Firefox? (Trying to move from Chrome to FF but need passwords)

    ReplyDelete
  7. Hello.. your blog is great. I read your blog and like it very much. Thanks for sharing.
    How to Lock Google Chrome with Password

    ReplyDelete