behsoh
safety

Keeping Accounts and Keys Safe While You Learn

Learning to program means collecting accounts, tokens, and keys at a surprising pace. A few habits started early prevent the mistakes that are painful to clean up later.

You now hold more secrets than you think

Within a few months of starting, a learner typically has an account on a code hosting service, a few accounts on services with APIs, and a growing pile of keys and tokens issued by them. Each is a way into something. Most security trouble for beginners does not come from clever attacks. It comes from a reused password, or from a key pasted into a file that was later made public.

Passwords: unique, long, and not memorised

The single most effective habit is to use a different password for every account. The reason is simple: when one service suffers a leak, attackers try the leaked passwords on other services. If each password is used once, a leak at one place stays at that place. Nobody can remember dozens of long random passwords, which is the job of a password manager: a program that stores them in an encrypted vault, protected by one strong password that you do memorise.

Add a second factor

Multi-factor authentication means that signing in needs something besides the password, typically a code from an app on your phone or a small hardware key. With it switched on, a stolen password alone is not enough. Turn it on first for your email account and your code hosting account. Email matters most, because password resets for nearly everything else are sent there.

When you enable a second factor, the service normally offers recovery codes. Store them somewhere safe that is not the phone itself. Losing the phone should be an inconvenience, not a lockout.

API keys are passwords for programs

A key or token lets a program act as you. Treat it exactly as you would a password, with one extra danger: programs live in files, and files get shared. The classic accident is writing a key directly into source code, committing it, and pushing the repository somewhere public. Automated scanners look for exactly this, and a published key can be found and misused quickly.

The usual remedy is to keep secrets out of the code entirely. A common approach is to have the program read the key from an environment variable, or from a small local configuration file that is listed in the version control ignore file so that it is never committed. The code then says "read the key from the environment", and the key itself exists only on your machine.

If a key leaks, replace it

If you discover a key in a commit, in a screenshot, or in a message you posted while asking for help, deleting it from view is not enough. Copies may already exist, and version history keeps old contents. Go to the service that issued the key, revoke it, and create a new one. Revoking is the only step that actually makes the leaked key harmless. Do that first, and tidy the history afterwards.

Give each key as little power as possible

Many services let you choose what a key may do: read only, or read and write; one project, or all of them. Choose the narrowest setting that lets your program work. This is the principle of least privilege, and its value shows on the bad day: a leaked read-only key for one project is a small problem, while a leaked key with full access to everything is a large one.

  • One unique password per account, kept in a password manager.
  • A second factor on email and code hosting first.
  • Keys in the environment or an ignored file, never in the source.
  • Narrow permissions and separate keys for separate projects.
  • On any leak: revoke, replace, then clean up.

Be careful what you paste

Asking for help often involves pasting code, logs, or terminal output. Before you post, read what you are about to share. Logs can contain tokens, addresses, and personal details. Replace anything secret with an obvious placeholder. It takes a moment and it becomes automatic.

Check the address before you sign in

Messages that urge you to sign in quickly are the usual way credentials are stolen. If a message says your account needs attention, do not follow its link. Open the site yourself, from a bookmark or by typing the address, and look there. A password manager helps here too, because it will not offer to fill a password on an address it does not recognise.

Keep an inventory

Once in a while, list the keys and tokens you have issued and delete the ones you no longer use. Old keys for abandoned experiments are still valid until someone revokes them. An unused key has no benefit and some risk, so removing it is always a gain.

Working rule: before every commit and before every paste, look for anything that would let a stranger act as you.

Last revised 2026-11-20 · Wendell Arkwright