Git Authentication
Personal access tokens, SSH keys, credential storage, and commit signing.
Listen
Transcript
Alex: Welcome back. Today we're talking about Git authentication, which is the part of GitHub that proves you are who you say you are before GitHub lets you change something.
Jamie: So this is the moment where Git stops being just, I can read this project, and becomes, I am allowed to push changes here.
Alex: Exactly. GitHub asks you to authenticate when you push commits, clone a private repository, or access organization repositories that require certain permissions. You usually do not need authentication to clone a public repository, view public code on GitHub.com, or read public issues and pull requests.
Jamie: And if somebody is only using the GitHub website or GitHub Desktop, they may not have to touch this appendix right away.
Alex: Right. This becomes most relevant when you're using VS Code with command-line Git and you want to push commits to your fork or another repository. The reference is set up with two main paths, a Personal Access Token path and an SSH key path, plus troubleshooting by exact error message. If you use a screen reader, heading navigation and numbered steps are useful here; if you use magnification, the code blocks and separate method sections help you keep the two paths apart.
Jamie: Okay, two paths. Is that the same as HTTPS versus SSH?
Alex: Yes. With HTTPS, your remote URL usually starts with https://github.com, and Git asks for a username and a credential. With SSH, your remote URL usually looks like git@github.com:owner/repo.git, and Git proves your identity with a key stored on your computer.
Jamie: The HTTPS credential is the Personal Access Token, right? Not my GitHub password.
Alex: Correct. A Personal Access Token, or PAT, is a password-like string you generate on GitHub and paste when Git asks for a password. GitHub has fine-grained tokens, which can be limited to specific repositories and permissions, and classic tokens, which are broader and still appear in many workshop instructions. The workshop reference recommends a classic token because it is straightforward to create through the web interface, but the security habit is the same either way: grant only the access you need.
Jamie: The nice part is that tokens work everywhere and are easy to revoke. The less nice part is that you have to store them safely, and they expire.
Alex: That's the tradeoff. SSH uses a key pair instead: a public key that you add to GitHub, and a private key that stays on your computer. Once SSH is set up, it usually stops prompting you, but the first setup is more command-line heavy. And the private key is secret; never paste it into GitHub, email, chat, or a repository.
Jamie: If I'm following the recommended workshop route, how do I make the token?
Alex: Start at github.com/settings/tokens. Choose Tokens classic, then generate a new classic token. Give it a clear note, such as Workshop Laptop Token, choose a short expiration like 30 or 60 days, and select the scopes you need. The common workshop scope is repo, and workflow is only needed if you will update GitHub Actions workflow files.
Jamie: And when GitHub shows the token, copy it right then. You don't get to come back and view it later.
Alex: Yes. If you're using a screen reader, the token appears as a long string in a text field, so select all, copy, and move it directly into a safe place. A password manager is best, an encrypted note can work, and a plain text file should only be temporary and only inside an encrypted folder.
Jamie: What should people avoid?
Alex: Do not paste the token into an unencrypted document that syncs to the cloud. Do not email it to yourself. And definitely do not save it in a public GitHub file. The next time Git asks for credentials, enter your GitHub username, and paste the token where Git asks for a password.
Jamie: This is where credential storage helps, because nobody wants to paste that long token every time.
Alex: Exactly. Git Credential Manager is the recommended cross-platform helper because it stores credentials securely and integrates with GitHub sign-in flows. On Windows, Git Credential Manager often remembers the token after first use. On macOS, Keychain may ask to save it, and you can choose Always Allow. On Linux, you can use Git Credential Manager too, or a temporary cache with git config --global credential.helper cache.
Jamie: What about the SSH path? I know people like it, but the words public key and private key can sound a little mysterious.
Alex: Start by checking whether you already have one. In a terminal, run ls -al ~/.ssh and look for files like id_rsa.pub or id_ed25519.pub. The .pub file is the public key, and the matching file without .pub is the private key.
Jamie: If there is no key, the command is ssh-keygen, right?
Alex: Yes. A common modern command is ssh-keygen -t ed25519 -C "your-email@example.com". When it asks where to save the key, pressing Enter accepts the default location. A passphrase is optional, but recommended, because it protects the key if someone gets access to your computer.
Jamie: Then we copy the public key, not the private one.
Alex: Exactly. In Windows PowerShell, you can use Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard. On macOS, use pbcopy < ~/.ssh/id_ed25519.pub. On Linux, you can run cat ~/.ssh/id_ed25519.pub, then manually select and copy the output.
Jamie: And that output should start with something like ssh-ed25519 or ssh-rsa.
Alex: Right. Then go to github.com/settings/keys, choose New SSH key, give it a title like Workshop Laptop SSH Key, set the key type to Authentication Key, paste the public key, and add it. GitHub may ask for your password or 2FA code. After that, test with ssh -T git@github.com, and a successful response starts with Hi username, you've successfully authenticated.
Jamie: Here's a very real question. What if I set up SSH perfectly, but my repository was cloned with HTTPS?
Alex: Then Git will still try to use the HTTPS route, because the remote URL controls the method. Run git remote -v to see the current remote. If you want SSH, set it with git remote set-url origin git@github.com:your-username/repo.git.
Jamie: And to go the other direction?
Alex: Use git remote set-url origin https://github.com/your-username/repo.git. This is worth checking before you regenerate tokens or keys, because the wrong remote URL can make a working credential look broken. HTTPS expects a token or credential helper, and SSH expects a configured key.
Jamie: Authentication errors can feel personal, but they usually have pretty specific causes.
Alex: They do. If you see Authentication failed when pushing, the token is often expired, mistyped, or stored incorrectly. Generate a new PAT, clear the old saved credential from Windows Credential Manager, macOS Keychain, or on Linux with git credential-cache exit, and push again so Git asks for credentials.
Jamie: What about Permission denied publickey?
Alex: That means SSH did not find a key GitHub accepts. Check that the public key is added at github.com/settings/keys, then run ssh-add -l to see what your SSH agent knows about. If your key is missing, add it with ssh-add ~/.ssh/id_ed25519.
Jamie: And Host key verification failed?
Alex: That means your computer does not recognize GitHub's host key yet, or the stored host key does not match. The reference gives ssh-keyscan github.com >> ~/.ssh/known_hosts as the direct fix. If anything about the warning seems unusual, pause and verify against GitHub's official SSH documentation before accepting a host key.
Jamie: Let's talk security habits, because tokens and keys are powerful.
Alex: Treat a PAT and a private key like passwords. Use the smallest token scopes that will do the job, set expiration dates on tokens, use a passphrase on SSH keys, and revoke old tokens when you're done with a project or device. Also, do not commit tokens, private keys, or local config files that contain secrets; use .gitignore for files that should stay on your machine.
Jamie: But the public key is different.
Alex: Yes. The public key is meant to be uploaded to GitHub and can be shared in that limited sense. The private key and tokens are the pieces that must stay protected.
Jamie: Commit signing sounds related, but it is not exactly the same as logging in, is it?
Alex: Right. Authentication lets you push or access a repository. Commit signing marks individual commits with a cryptographic signature, and GitHub can show a Verified badge when the signature matches a key connected to your account.
Jamie: So maintainers can see that the commit really came from a trusted key, not just from a name and email typed into Git config.
Alex: Exactly. There are two common signing methods. SSH signing is simpler for many learners because it can reuse an SSH key you already have, though you still add it to GitHub as a signing key and configure Git for SSH signing. GPG signing is the older traditional method and has more setup steps.
Jamie: Give me the short version of SSH signing first.
Alex: You tell Git to use SSH for signing with git config --global gpg.format ssh. Then you set your signing key, usually pointing Git at your public SSH key file, and turn on signing with git config --global commit.gpgsign true. In GitHub settings, add the same public key as a signing key, not just an authentication key.
Jamie: And the GPG route is the one with key IDs and the public key block.
Alex: Yes. You generate a GPG key with gpg --full-generate-key, choose RSA and RSA, 4096 bits, and usually no expiration if that is what your organization expects. Use the email address associated with your GitHub account. Then find the key ID with gpg --list-secret-keys --keyid-format=long; the output includes something like sec rsa4096/XXXXXXXXXXXXXXXX, and the X part is the key ID.
Jamie: Then export the public part and add it to GitHub.
Alex: Right. Export it with gpg --armor --export followed by the key ID, and copy the block that starts with BEGIN PGP PUBLIC KEY BLOCK. Add that public key in GitHub's SSH and GPG keys settings. Then configure Git with your signing key ID and turn on commit.gpgsign true so future commits are signed automatically.
Jamie: Where does Vigilant Mode fit into this?
Alex: Vigilant Mode is a GitHub account setting that makes commit verification more visible and stricter in how unsigned or unverified commits are shown. Some maintainers use it because they want a clearer signal about which commits were signed by trusted keys. As a contributor, you may see badges such as Verified, Unverified, or Partially verified beside commits.
Jamie: If you're using a screen reader, don't just assume the icon color tells the whole story.
Alex: Right. Move to the badge text near the commit, and open the badge details when you need the reason. GitHub will usually explain whether the signature is valid, missing, attached to an unknown key, or tied to an email mismatch.
Jamie: For this workshop, the practical recommendation is still pretty calm.
Alex: Use a Personal Access Token if you need a straightforward way to push from the command line. Use SSH if you're comfortable with terminal setup and want a smoother long-term flow. Commit signing is valuable, especially in security-conscious projects, but it is usually something to add after your basic push workflow is working unless a repository specifically requires it.
Jamie: So the pattern is: choose HTTPS with a token or SSH with a key, store secrets safely, check your remote URL, and troubleshoot from the exact error message.
Alex: Exactly. Authentication is GitHub checking whether the person asking to change a repository is allowed to do it. Once that is set up, push, pull, and contribution work get much quieter.
Workshop Content
Companion Podcast and Transcript
Use audio and transcript companions to review concepts in a conversational format.
Git Authentication
Companion audio: this episode reinforces key ideas and may not be a word-for-word reading of this page.
Open audio file (external) Full transcript source (external)
Transcript preview
Alex: Welcome back. Today we're talking about Git authentication, which is the part of GitHub that proves you are who you say you are before GitHub lets you change something.
Jamie: So this is the moment where Git stops being just, I can read this project, and becomes, I am allowed to push changes here.
Alex: Exactly. GitHub asks you to authenticate when you push commits, clone a private repository, or access organization repositories that require certain permissions. You usually do not need authentication to clone a public repository, view public code on GitHub.com, or read public issues and pull requests.
Jamie: And if somebody is only using the GitHub website or GitHub Desktop, they may not have to touch this appendix right away.
Appendix D: Git Authentication
Listen to Episode 21: Git Authentication - a conversational audio overview of this chapter. Listen before reading to preview the concepts, or after to reinforce what you learned.
Reference companion to: Chapter 00: Pre-Workshop Setup | Also relevant: Chapter 14
Authoritative source: GitHub Docs: Authenticating with GitHub from Git
SSH Keys & Personal Access Tokens
Audience: This appendix is for contributors who need to configure Git authentication for push access. If you're working entirely through the GitHub web interface or GitHub Desktop, you can skip this. If you're using VS Code with Git command line, this becomes relevant when you want to push commits to your fork.
Learning Cards: Using This Authentication Reference
Screen reader users
- This appendix has two main paths: Personal Access Token (recommended) and SSH Keys -- jump to your chosen method via heading navigation
- Step-by-step instructions are numbered lists -- your screen reader announces "1 of 8," etc. to track progress
- The Troubleshooting section near the bottom covers the error messages you are most likely to encounter
Low vision users
- Command-line examples are in code blocks with high contrast -- increase zoom to read them comfortably
- Each method (PAT vs SSH) is a separate section with its own step-by-step flow
- The "Do not" lists use bold text to highlight security warnings
Sighted users
- Start at "Two Authentication Methods" for a pros/cons comparison, then follow the section for your choice
- Code blocks show the exact commands to copy -- use the copy button in the top-right corner on GitHub
- The Troubleshooting section at the bottom is organized by error message
When You Need Authentication
GitHub requires authentication when you:
- Push commits to a repository
- Clone a private repository
- Access organization repositories with specific permissions
You do not need authentication to:
- Clone public repositories
- View public repositories on GitHub.com
- Read issues and pull requests
Two Authentication Methods
Personal Access Token (PAT)
A Personal Access Token is a password-like string you generate on GitHub and use instead of your account password when Git asks for credentials.
Pros
- Works on all operating systems
- Easy to set up for screen reader users (no command line required)
- Can be scoped to specific permissions
- Easy to revoke if compromised
Cons
- You have to store it securely
- Expires after a set time (you must regenerate)
SSH Keys
SSH uses public-key cryptography. You generate a key pair on your computer (public + private), upload the public key to GitHub, and Git uses the private key to prove your identity.
Pros
- Once set up, works automatically (no password prompts)
- More secure than tokens
- Never expires
Cons
- Requires command-line setup (less accessible for some screen reader users)
- Slightly more complex initial configuration
Creating a Personal Access Token (Recommended for This Workshop)
Why this method: It's screen reader accessible through the GitHub web interface, and you can complete it without command-line Git configuration.
Step 1: Generate the Token
- Navigate to github.com/settings/tokens
- Select "Tokens (classic)" from the left sidebar
- Activate "Generate new token" → Select "Generate new token (classic)"
- Give it a descriptive name in the Note field: "Workshop Laptop Token"
- Set expiration: 30 days or 60 days (recommended for temporary workshop use)
- Select scopes:
repo- Full control of private repositories (includes public repo access)workflow- Update GitHub Actions workflows (if you'll work with Actions)
- Scroll down and activate "Generate token"
- CRITICAL: Copy the token immediately - you cannot see it again
Screen reader note: The token appears as a long string in a text field. Select all (Ctrl+A), copy (Ctrl+C), and paste it into a secure note or password manager.
Step 2: Store It Securely
Options
- Password manager (1Password, Bitwarden, LastPass) - best option
- Encrypted note in your operating system's secure notes
- Plain text file in an encrypted folder (temporary only)
Do not
- Paste it into a document you sync to cloud storage unencrypted
- Email it to yourself
- Save it in a public GitHub file
Step 3: Use It
The next time Git asks for your password (when you push, pull from a private repo, or clone a private repo):
Username: [your-github-username]
Password: [paste-your-PAT-here]
Windows Git Credential Manager: Windows will remember this token automatically after your first use. You only paste it once.
macOS Keychain: macOS will offer to save it to Keychain. Select "Always Allow."
Linux: You can configure Git to cache credentials:
git config --global credential.helper cache
Setting Up SSH Keys (Alternative Method)
If you prefer SSH and are comfortable with terminal commands:
Step 1: Check If You Already Have a Key
ls -al ~/.ssh
Look for files named id_rsa.pub, id_ed25519.pub, or similar. If you see these, you already have a key.
Step 2: Generate a New SSH Key
ssh-keygen -t ed25519 -C "your-email@example.com"
When prompted:
- Press
Enterto accept the default file location - Enter a passphrase (optional but recommended)
Screen reader note: Git will print output showing where the key was saved. It generates two files: id_ed25519 (private) and id_ed25519.pub (public).
Step 3: Copy Your Public Key
Windows (PowerShell)
Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard
macOS
pbcopy < ~/.ssh/id_ed25519.pub
Linux
cat ~/.ssh/id_ed25519.pub
# Manually select and copy the output
Step 4: Add to GitHub
- Navigate to github.com/settings/keys
- Select "New SSH key"
- Title: "Workshop Laptop SSH Key"
- Key type: Authentication Key
- Key: Paste your public key (should start with
ssh-ed25519orssh-rsa) - Select "Add SSH key"
- Confirm with your password or 2FA code
Step 5: Test the Connection
ssh -T git@github.com
You should see: Hi username! You've successfully authenticated...
Step 6: Use SSH URLs
When cloning or adding remotes, use SSH URLs instead of HTTPS:
# SSH format
git@github.com:owner/repo.git
# Instead of HTTPS
https://github.com/owner/repo.git
Switching Between HTTPS and SSH
If you cloned with HTTPS but want to use SSH (or vice versa), update the remote:
Check your current remote
git remote -v
Switch to SSH
git remote set-url origin git@github.com:your-username/repo.git
Switch to HTTPS
git remote set-url origin https://github.com/your-username/repo.git
Learning Cards: Troubleshooting Authentication
Screen reader users
- Each troubleshooting entry starts with the error message in quotes as an h3 heading -- press 3 to jump between errors
- Solutions include terminal commands in code blocks -- switch to Focus Mode before copying them
- If your error is not listed here, search the GitHub Docs authentication troubleshooting page
Low vision users
- Error messages are displayed as bold h3 headings for easy visual scanning
- Solution steps are numbered and include code blocks you can copy directly
- If terminal output is hard to read, paste commands into VS Code's integrated terminal which respects your theme settings
Sighted users
- Scan the h3 headings to find your exact error message
- Each solution starts with the most common fix first -- try that before the alternatives
- The "Security Best Practices" section below is worth skimming after you resolve your issue
Troubleshooting
"Authentication failed" when pushing
Problem: Your token expired or is incorrect.
Solution
- Generate a new PAT
- Clear your credential cache (Windows: Credential Manager; macOS: Keychain; Linux:
git credential-cache exit) - Try pushing again - Git will ask for credentials
"Permission denied (publickey)"
Problem: SSH key not properly set up.
Solution
- Verify your key is added to GitHub: github.com/settings/keys
- Check SSH agent is running:
ssh-add -l - Add your key to the agent:
ssh-add ~/.ssh/id_ed25519
"Host key verification failed"
Problem: SSH doesn't recognize GitHub's host key.
Solution
ssh-keyscan github.com >> ~/.ssh/known_hosts
Security Best Practices
- Never share your private key or PAT - treat them like passwords
- Use scoped PATs - only grant the minimum permissions needed
- Set expiration dates on PATs - regenerate periodically
- Use a passphrase on SSH keys - adds another layer of security
- Revoke old tokens when you're done with a project or device
- Don't commit tokens or keys to Git - use
.gitignorefor config files
Commit Signing - Verified Badges and Vigilant Mode
When you push commits to GitHub, each commit shows a small badge: Verified or Unverified. This badge tells anyone viewing the commit history whether the commit was cryptographically signed - proving it came from you and was not tampered with.
Why It Matters
Open source maintainers increasingly require signed commits before merging. Some repositories enforce this with branch protection rules. If you contribute to accessibility-agents and your commits show "Unverified," a maintainer may ask you to sign them before the PR can be merged.
Two Methods for Signing Commits
SSH Signing (simpler - reuses your existing SSH key)
If you already have an SSH key set up for authentication, you can use it for signing too.
Step 1: Configure Git to use SSH for signing
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true
Step 2: Add your SSH key as a signing key on GitHub
- Navigate to github.com/settings/ssh
- Select "New SSH key"
- Change "Key type" to "Signing Key" (not Authentication Key)
- Paste your public key and save
Your commits now show the Verified badge in GitHub's commit history.
GPG Signing (traditional method)
Step 1: Generate a GPG key
gpg --full-generate-key
# Choose: RSA and RSA, 4096 bits, never expires
# Enter your GitHub email address when prompted
Step 2: Find your key ID
gpg --list-secret-keys --keyid-format=long
# Output includes: sec rsa4096/XXXXXXXXXXXXXXXX
# The X's are your key ID
Step 3: Export the public key
gpg --armor --export YOUR_KEY_ID
# Copies the block starting with -----BEGIN PGP PUBLIC KEY BLOCK-----
Step 4: Add to GitHub
- Navigate to github.com/settings/gpg-keys
- Select "New GPG key" → paste the exported public key
Step 5: Configure Git to sign all commits
git config --global user.signingkey YOUR_KEY_ID
git config --global commit.gpgsign true
Vigilant Mode
GitHub has an optional setting called Vigilant Mode (in Settings → SSH and GPG Keys → Vigilant mode). When enabled, GitHub marks all commits from your account as "Unverified" unless they are signed - even commits that were previously shown without a badge.
Why some maintainers enable Vigilant Mode
- It makes tampered or spoofed commits immediately obvious
- It signals that the repository cares about commit provenance
What you see as a contributor
- Every unsigned commit you push will show a yellow "Unverified" badge
- This is a visual signal - commits can still be pushed, but maintainers may block the merge
To read verification badges with a screen reader
- Navigate to the repository's commit history (Code tab → Commits link)
- Each commit row contains either "Verified" or "Unverified" as a badge element
- NVDA/JAWS: the badge is inside the commit row; use
↓to read through each row and the badge text is read inline - VoiceOver: use
VO+Rightthrough the commit row; the badge is read as a button with the text "Verified" (clicking it shows the certificate)
Workshop recommendation: SSH signing is simpler to set up than GPG and reuses your existing key. If you have 10 minutes, configure it before Day 2 - every commit you push to accessibility-agents will show as Verified.
For This Workshop
Recommended approach
- Generate a Personal Access Token with 30-day expiration
- Scope:
repoandworkflow - Store it in your password manager
- Use it when VS Code or Git asks for a password
SSH keys are great for long-term use, but PATs are faster to set up and more accessible for screen reader users during a time-constrained workshop.
Next: Appendix E: Advanced Git
Back: Appendix C: Markdown Reference
Teaching chapter: Chapter 00: Pre-Workshop Setup
Authoritative Sources
Use these official references when you need the current source of truth for facts in this chapter.
- GitHub Docs, home
- GitHub Changelog
- GitHub security features
- Dependabot docs
- Secret scanning docs
- Git authentication overview
- Managing personal access tokens
Section-Level Source Map
Use this map to verify facts for each major section in this file.
- SSH Keys & Personal Access Tokens: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- When You Need Authentication: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Two Authentication Methods: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Creating a Personal Access Token (Recommended for This Workshop): GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Setting Up SSH Keys (Alternative Method): GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Switching Between HTTPS and SSH: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Troubleshooting: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Security Best Practices: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- Commit Signing - Verified Badges and Vigilant Mode: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs
- For This Workshop: GitHub Docs, home, GitHub Changelog, GitHub security features, Dependabot docs, Secret scanning docs