GitHub accounts, SSH keys and authentication
Prove who you are to GitHub from the command line: generate an ed25519 SSH key, add the public half to your account, and know when HTTPS tokens fit better.
Installing and configuring GitRemotes, clone and originFetch, pull and push
GitHub accounts, SSH keys and authentication
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- GitHub identifies a commit's author by the email address in your Git config, and authenticates a push by a separate credential, so setting user.email and setting up SSH are different jobs.
- An SSH key is a pair: the private half stays on your machine and the public half goes into your GitHub account settings.
- Run ssh -T git@github.com to test a key; success greets you by username, and Permission denied (publickey) means GitHub did not accept any key you offered.
- Over HTTPS, Git asks for a personal access token in place of a password, because password authentication for Git has been removed.
- Protect the private key with a passphrase and an agent, never paste it anywhere, and compare the host fingerprint before you type yes.
Two questions GitHub asks
Every push involves two separate questions. Who wrote this commit? That is answered by the author email stored inside the commit, which comes from your Git config. Who is allowed to push it? That is answered by a credential you present when you connect.
People mix these up, so keep them apart. You can set user.email correctly and still be refused a push, and you can authenticate perfectly and still produce commits that GitHub does not link to your profile.
For attribution, add your email to your account and verify it, so commits that carry that address show your avatar and count in your contributions. If you do not want a real address in public history, GitHub offers a Keep my email addresses private option under Settings, Emails, and a no-reply address to put in user.email instead. For authentication, you have two options: SSH or HTTPS.
Why SSH keys
A password has to be sent to the server, and anyone who sees it can reuse it. An SSH key uses a key pair instead. You generate two linked files. The private key never leaves your machine. The public key can be shared freely. To log in, your machine proves it holds the private key by signing a challenge, and the server checks the signature against the public key. Nothing secret crosses the network.
The analogy is a padlock and its key. You can hand out copies of the open padlock (the public key) to every door you want to use. Only you have the key that opens it.
Generating a key
ssh-keygen -t ed25519 -C "ada@example.com" -f ~/.ssh/id_ed25519_github
ed25519 is a modern, compact key type, and it is what GitHub’s docs use. -C is just a label. When prompted, set a passphrase, which encrypts the private key on disk so a stolen laptop does not mean a stolen identity.
I ran this with a throwaway key and OpenSSH 10.5. It created id_ed25519_github with mode 600 (only you can read it) and id_ed25519_github.pub with mode 644. ssh-keygen -lf id_ed25519_github.pub printed the fingerprint SHA256:5Pz7sw… and (ED25519). With a passphrase set, ssh-keygen -y with the wrong one printed incorrect passphrase supplied to decrypt private key, so the encryption does work.
Typing the passphrase for every push gets old, so load the key into an agent once per session:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_github
ssh-add -l # lists the loaded keys by fingerprint
I confirmed ssh-add printed Identity added and ssh-add -l showed the same fingerprint. To pick the key automatically for GitHub, put this in ~/.ssh/config:
Host github.com
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519_github
IdentitiesOnly yes
I checked it parses by running ssh -G -F <that file> github.com, which reported the identity file and identitiesonly yes. macOS has an extra keychain option, and GitHub’s docs cover it. I did not test that.
Adding it to GitHub
Print the public key and copy it:
cat ~/.ssh/id_ed25519_github.pub
In GitHub, click your profile picture, then Settings, then SSH and GPG keys in the sidebar, then New SSH key. Give it a Title you will recognise (such as “Work laptop”), paste into the Key field, and click Add SSH key. The form also asks whether the key is for authentication or signing. For pushing and pulling, choose authentication. Signing commits is the signing commits and tags lesson.
I could not do this step. I have no GitHub account in the environment where I wrote this lesson. I took the labels from GitHub’s docs, which I read on 2026-11-23. The docs do not give the dropdown’s exact wording, which is why I describe it instead of quoting it.
Testing it
ssh -T git@github.com
The first time, SSH asks whether to trust github.com and shows a fingerprint. Compare it with GitHub’s published value before typing yes. For ED25519 it is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. I ran ssh-keyscan -t ed25519 github.com | ssh-keygen -lf - and got exactly that string, which matches the docs. On success you see Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
I could only show the failure case. With a throwaway key that is not on any account, ssh -T git@github.com answered Permission denied (publickey). That message means no key you offered was accepted. Check that the public key is on your account, that ssh-add -l lists the key, and that IdentitiesOnly is not hiding it.
One more thing I confirmed: cloning a public repository over HTTPS needs no credentials, but the same repository over git@github.com: was refused without a key. SSH always requires an identity, even to read.
The HTTPS alternative
An HTTPS remote looks like https://github.com/ada/notes-cli.git and works anywhere, including behind firewalls that block port 22. When Git asks for a password it wants a personal access token instead, because password authentication for Git has been removed. Create one under Settings, Developer settings, Personal access tokens. GitHub recommends fine-grained tokens limited to chosen repositories, with an expiry, over classic ones. A credential helper such as Git Credential Manager stores the token so you are not asked again. Treat a token like a password.
The GitHub CLI lesson shows gh auth login, which can do this setup for you.
What the video covers
NeuralNine’s “Create & Add SSH Keys To GitHub For Authentication” is about six minutes and was published around 2025. Its description is one line saying it covers creating and using SSH keys on GitHub for authentication. I could not read a transcript, so I do not know which operating system it demonstrates or whether it uses a passphrase. English is judged from the title and description. It is short on purpose, so treat it as the click-through to match the steps above.
Where this fits
You can now authenticate. Next you will put the notes project on GitHub: creating and publishing a repository.
Check yourself
Which file must you never upload to GitHub or share: id_ed25519 or id_ed25519.pub?
id_ed25519, the private key. The .pub file is the public half, and uploading it to GitHub is exactly what you are meant to do.
Your push says Permission denied (publickey). What does that tell you?
The server did not accept any key your machine offered. Usually the public key is not on your account, the wrong key is being offered, or the key is not loaded in the agent.
Why are user.email in Git config and the SSH key separate settings?
The email is written into each commit as the author, and GitHub matches it to a verified address on your account to attribute the commit. The SSH key only proves who is pushing. Neither implies the other.
When would you choose HTTPS with a token over SSH?
When port 22 is blocked by a firewall or proxy, or when a tool such as a CI job already has a token. HTTPS works everywhere but needs a token or credential helper.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.