Isolate Work in Firefox

Like a large number of people around the world right now, my place of work has closed the doors for safety concerns. I’m fortunate enough to be in a position to work from home via VPN, but I did want to keep some separation between my work and non-work environments.

The full-separation route would be creating a new user profile on my local machine. This would ensure complete separation. I didn’t go this route because I don’t need to keep everything separate. A fair amount of my work is already isolated via RDP (to a Windows machine) or ssh (to my workstation and development servers). The biggest remaining concern was Firefox – keeping all my work logins (Office 365, issue tracker, etc) from intermingling with my personal accounts.

There are several ways to accomplish this:

  • Firefox Containers is an easy one, is built-in, and easily configurable. Problem is it’s per-tab, so I can have a dozen tabs with different container contexts. Furthermore, I can’t just click the new-tab button and get to my issue tracker, I need to select the correct context every time.

  • Use a different browser. I could install Chrome for work. I don’t want to.

  • Use Firefox Profiles. This is the ideal solution for me, as it allows window-level separation, but also can provide alt-tab separation with an intelligent window manager (GNOME, for example).

Create a new profile

$ firefox --no-remote -P

There’s a few things going on here:

  • --no-remote tells Firefox to start a new instance, instead of telling any running Firefox to start a new window

  • -P will open the profile manager

Firefox Profile Manager

Click “Create Profile”, and give it a name. Simpler is better. I used “work”.

Create a desktop shortcut

I need Gnome to know how to run and manage this Firefox instance.

The key details are that the name, class, and .desktop filename all match. This is the heuristic GNOME uses to group windows.

$ cat .local/share/applications/firefox-work.desktop 
[Desktop Entry]
Name=Firefox for Work
Comment=Firefox Work profile
Exec=firefox --name=firefox-work --class=firefox-work --no-remote -P work
# If you have a logo icon you want to use instead, you can use a path:

Note instead of just -P, we provided a profile name, -P work. This tells Firefox to run that profile, instead of the standard one.

I strongly suggest setting a custom icon.

Run Firefox for Work

Now when you type “Firefox”, you’ll have an additional entry. Note that in this screenshot, I also have Firefox installed via flatpak, so I’ve got a third icon that can be safely ignored.

Firefox in Gnome Shell

The nice thing is that this is grouped separately in ALT+TAB as well, so you can ALT+TAB to your work Firefox, hit CTRL+N, and bring up whatever logged-in work account you want. Your Work browsing is no longer intermingling with your personal browsing,

Firefox always uses my work profile now!

Run firefox -P again, select your normal default profile, and ensure the “use the selected profile without asking at startup” box is checked. This will re-set the default.

Privacy caveat

Depending on your VPN, your personal Firefox may still be doing DNS lookups and possibly even routing via your work VPN, just like normal. This simply keeps profiles, accounts, passwords, and (most importantly) workflow separate.