1

Google's Chrome browser (and Chromium) stores the saved passwords in a encrypted sqlite database where it is pretty safe. However, if the user is logged into Chrome, it is merely a matter of a few mouse clicks to reveal the passwords.

Because of that I would like to make a script that will automatically log me out of Chrome based on certain criteria, such as when my Linux PC is connected to a foreign network (which would be the case if it were stolen).

The script itself is not my main problem. What I don't know, however, is how to force Chrome to log me out using the command line.

Is that possible?

  • 1
    It sounds like you want to avoid losing all your passwords if your computer ever gets stolen. Logging out of Chrome isn't the answer to this. – wersimmon Sep 23 '13 at 22:43
  • It is part of the answer. There are more safety precautions such as a encrypted home folder. – marlar Sep 24 '13 at 7:35
3

You should consider other more general security measures to protect the data of a running or suspended system:

  • (automatically) lock your sessions when away from keyboard,
  • encrypt your home directory or partition,
  • encrypt the suspend image (dm-crypt, uswsusp, or tuxonice will do the job),
  • encrypt the swap partition (dm-crypt), and
  • use one or multiple strong pass phrases or even a smartcard in all of the above instances.

At this point it doesn't matter much, if the browser still has the master key in memory.

Rationale

If someone steals your notebook, he would have to guess your key, break the encryption, or analyse the memory content in case of a live system. The latter two are considered very difficult to achieve, whereas the difficulty of the first depends on the complexity of your key.

2

Just posting this because I couldn't find the answer... The trick is all about https://mail.google.com/mail/?logout&hl=en which logs you out.

For Conf room machines that may be left logged in and are set to always be running.

Create a bash file called LogOutOfChome.sh in ~/ with contents:

#!/bin/bash
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin

pkill -a -i "Google Chrome"
sleep 3
Open -a "/Applications/Google Chrome.app" --args 'https://mail.google.com/mail/?logout&hl=en'
sleep 15
pkill -a -i "Google Chrome"

This kills all open instances of Chrome, waits 3 seconds, opens the Gmail logout URL, waits 15 seconds, then kills all instances of Chrome again.

From the terminal: chmod +x LogOutOfChrome.sh, which will make it executable.

Test it (note, this will close all your Chrome windows and log you out…..) ./LogOutOfChrome.sh

Use crontab to schedule it. crontab -l (this is a lower case L) to list if you have anything else scheduled.
Edit your crontab with VI. crontab -e
Type i (lower case I) to insert
Copy/Paste:

*   1   *   *   *   ~/LogOutOfChrome.sh

Hit Esc, enter :wqEnter to Write and Quit.  This will run the script at (minute, hour, day month, day of week) at hour 1 (i.e., 1 AM) of each day.

To test this, if it was currently 2:15pm set it to:

17  14  *   *   *   ~LogOutOfChrome.sh

which is 17 minutes past 14:00 hours (i.e., 2:17 PM).

1

use an external password program that can be set up with requiring a passcode generated by an app on your smartphone, or that can send a text with a one time password to access their database. My personal preference is LastPass.

pkill can be used to kill off processes - if you set up chrome to not remember your login details when starting a new session, this would be sufficient (settings > content settings > manage exceptions > add pattern: google.com > dropdown: clear on exit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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