Setting Up GitHub SSH Keys and Cryptographic Signing
In this tutorial, you will configure an enterprise-grade SSH workflow for GitHub. You will generate an ED25519 SSH key pair, configure non-interactive workstation authentication, register the key with GitHub for both repository operations and commit signing, and verify your signatures against branch protection rules.
Prerequisites
Before starting, ensure your workstation has the following tools installed and accessible from your terminal:
- Git version 2.34 or higher (required for native SSH commit signing support).
- OpenSSH client (
sshandssh-keygen). - GitHub CLI (
gh) (optional, recommended for automated key registration). - An active GitHub account with access to the tupynambalucas-dev organization.
Step 1: Generate an ED25519 Key Pair
We recommend the ED25519 public-key algorithm over RSA. ED25519 keys are cryptographically stronger, faster, and more compact.
-
Open your terminal and run
ssh-keygen:ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/github_ed25519 -
When prompted for a passphrase:
- For an automated or non-interactive workstation workflow, press
Entertwice to proceed without a passphrase. - For environments requiring encryption at rest, enter a strong passphrase and use an SSH agent with credential caching.
- For an automated or non-interactive workstation workflow, press
-
Verify that the key pair was created in your
~/.sshdirectory:ls -la ~/.ssh/github_ed25519*You will see two files:
github_ed25519: Your private key. Never share, commit, or expose this file.github_ed25519.pub: Your public key. This key will be uploaded to GitHub.
Step 2: Configure the SSH Client
Create or edit your local SSH configuration file (~/.ssh/config) to automatically route connections to github.com through your dedicated key.
-
Open or create
~/.ssh/config:Host github.comHostName github.comUser gitIdentityFile ~/.ssh/github_ed25519IdentitiesOnly yesServerAliveInterval 60 -
Set appropriate filesystem permissions on the
.sshdirectory and configuration files:chmod 700 ~/.sshchmod 600 ~/.ssh/config ~/.ssh/github_ed25519chmod 644 ~/.ssh/github_ed25519.pubWindows EnvironmentsOn Windows systems using PowerShell, OpenSSH respects permissions inherited from user security identifiers. The configuration above applies natively in Windows Terminal and PowerShell when using the system OpenSSH feature.
Step 3: Register the Key on GitHub
GitHub distinguishes between two key types. To satisfy organization security policies and branch protection rules, your public key must be registered for both:
- Authentication Key: Authorizes Git transport operations (
git fetch,git clone,git push) over SSH. - Signing Key: Cryptographically verifies your commits and tags, displaying the green Verified badge.
Option A: Using the GitHub CLI (Recommended)
-
Upload the key for authentication:
gh ssh-key add ~/.ssh/github_ed25519.pub --title "Workstation Authentication" --type authentication -
Upload the same key for cryptographic commit signing:
gh ssh-key add ~/.ssh/github_ed25519.pub --title "Workstation Commit Signing" --type signing
Option B: Using the GitHub Web Interface
-
Copy your public key to your clipboard:
# Windows PowerShellGet-Content ~/.ssh/github_ed25519.pub | Set-Clipboard# macOSpbcopy < ~/.ssh/github_ed25519.pub# Linuxxclip -sel clip < ~/.ssh/github_ed25519.pub -
Navigate to GitHub SSH and GPG keys settings.
-
Click New SSH key.
-
In the Title field, enter an identifier (e.g.,
Workstation ED25519). -
In the Key type dropdown, select Authentication Key, paste your key, and click Add SSH key.
-
Click New SSH key again.
-
Enter the title (e.g.,
Workstation Signing ED25519), select Signing Key in the Key type dropdown, paste the key, and click Add SSH key.
Step 4: Configure Git for Native SSH Signing
Configure Git globally to use SSH for commit signing instead of GPG.
-
Set SSH as the signing format:
git config --global gpg.format ssh -
Specify the public key path as your signing identity:
git config --global user.signingkey ~/.ssh/github_ed25519.pub -
Enable automatic commit signing across all repositories:
git config --global commit.gpgsign true -
Configure Git to automatically rewrite HTTPS GitHub URLs to SSH:
git config --global url."[email protected]:".insteadOf "https://github.com/" -
Confirm your Git configuration:
git config --global --get gpg.formatgit config --global --get user.signingkeygit config --global --get commit.gpgsign
Step 5: Test Connectivity and Verify a Signed Commit
-
Verify the SSH connection to GitHub:
ssh -T [email protected]You should receive a welcome response confirming your username:
Hi username! You've successfully authenticated, but GitHub does not provide shell access. -
Make a signed commit in your local repository:
git commit -m "chore: test cryptographic ssh commit signature"Manual Signing FlagBecause
commit.gpgsignis set totrue, all commits are signed automatically. You can explicitly sign using the-Sflag (git commit -S -m "..."). -
Inspect the cryptographic signature locally:
git log --show-signature -1The log output will confirm a valid SSH signature:
commit 0a1b2c3...Good "git" signature for [email protected] with ED25519 key ... -
Push the branch to GitHub:
git push origin develop -
Open the commit in GitHub. The commit header will display the verified badge, satisfying all organization branch protection constraints.