How to create a backdoor for your Google account so you will never* get locked out again 🔑💻
Tags: google, 2fa, security, backdoor
Published: 2022-08-01 21:58:00

## Locked out again...
Today a friend sent me an article from HackerNews title [Librarian's Letter to Google Security](https://news.ycombinator.com/item?id=32304320). As someone who teaches Digital Literacy, this breaks my heart and it's a story I know well. I'll paste some quotes here:

> _The way Google’s two-factor authentication system is designed, sets up poor and elderly people to be locked out of their accounts again and again, and without access to their email, they lose their welfare benefits, their housing, and struggle to find work._

>  _This elderly woman, looked to be in her 70s, might lose the roof over her head, due to being unable to log into her Google account, because she lost her old phone and with it, her phone number._

> ... **no support line to turn to**. It is a daily occurrence, ...

And you can imagine there is much more. [Here is the link to the actual letter](https://docs.google.com/document/d/1f6HPQbUjslcbjVHkJkAgYmQmBV3PRRHEcx4WL5rxuE8/preview), which is hosted on Google Docs.

## The light at the end of the tunnel...

The good news is _there is a way._ A little while back I created a way to essentially make my own Google account backdoor, a backdoor known only to me. Conceptually this is somewhat similar to a [port-knocking script](https://wiki.archlinux.org/title/Port_knocking). Do this now, **before** you get locked out of your account. If you're already locked out, this can't help you. Also, the idea is to set this up on the account you want to regain access to, but you can also create a secondary email just for this purpose. It's your call.

👍 It may be helpful to understand some requisite concepts in order to set this up. The first is [Google Backup Codes](https://support.google.com/accounts/answer/1187538). Another is [Gmail Templates](https://support.google.com/a/users/answer/9308990), and the last one is [Gmail Filtering](https://support.google.com/mail/answer/6579).

## Get to the point, dude.

#### For you more advanced readers, this is the tl;dr version of the steps:

1. Generate a list of one-time-use backup codes in Google Account Settings.
2. Copy the list of backup codes into a Gmail Template.
3. Set up a filter in Gmail that looks for a _very specific string_ in an incoming email. Configure the filter to autoreply to the incoming email with the gmail template.
4. If you are ever locked out of your account, email yourself from a throwaway with the _very specific string_ you have chosen. Your robot-email will autoreply with the list of access codes. Voila, you have regained access to your account.

## The full version of the recipe:
### Step 1: Generate Backup Codes
Go to your [Google Account](https://myaccount.google.com/). Go to Security Settings and click 2FA. You should see an option for **Backup Codes** there that looks like this: ![backup codes image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnhkjhcxbn7vqgjexqb3.png)
Click on it and create some backup codes.
![list of backup codes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhbm5hnrk2oj9z84e42d.png) I have edited out my backup codes here, but there are ten eight-digit numbers. You may have to enable some other form of 2FA (adding a phone number) as well to be able to generate backup codes.
### Step 2: Paste into a Template
Now, enable Gmail Templates.
- Open Gmail.
- At the top right, click Settings > **See all settings**.
- At the top, click **Advanced**.
- In the **Templates** section, select **Enable**.
- At the bottom, click **Save Changes**.

Create an email, then paste in your access codes into the email body. Do not put any recipients into the _To:_ field. You can put whatever subject line you like.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qrs8zkis9e3cew3e1a5.png)
Click the **Three Dots** > **Templates** > **Save Draft As Template** > **Save as New Template** and you will be prompted to enter a new Template name.

### Step 3: Set up a Filter with an auto-reply
In Gmail, click this at the top:
![filter icon from gmail](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzhipq17eiw5pnetd7a9.png) and a search filter panel will appear. Type in something _very specific_, known only to you, that would _never_ realistically appear as a subject line to a normal email. In this example I have chosen

> One giant leap for mankind.

But you can use whatever you want. The longer the better. I recommend something that you can easily remember; a movie quote works well.
![search panel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqghd8odwxghuqx0m3su.png)

Once you've typed your phrase into the _Subject:_ line, click **Create Filter** and a new panel will pop up with some check boxes:
![checkboxes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5f7v204ssmsdsi8iyyu.png)
Check the one where it says **Send Template** with a drop-down box. Choose the new template you just made and click **Create Filter**

Now, you can test it. Use a junk email address and send an email to your Gmail email address with the _very specific string_ as the subject line you chose. I used my work email address to test mine, and it auto-replied right away.

### ⚠WARNING⚠: 
_There is **one** caveat to all this: Be careful you don't use all the storage capacity of your Google account. Google has an automated policy where if you use up all your storage space, email comes to a grinding halt. So beware of that._

## But that's it. Good luck out there, internet friends!