How to Create an SSH Key for GitHub (Step-by-Step Guide)
If you've ever typed your GitHub username and password repeatedly just to push a commit, SSH keys are the fix. They let your machine authenticate with GitHub automatically — securely, without a password prompt every time. Here's exactly how SSH keys work and how to set one up.
What Is an SSH Key and Why Does GitHub Use It?
SSH (Secure Shell) is a cryptographic protocol for secure communication between two machines. When you connect to GitHub via SSH, your identity is verified using a key pair — two mathematically linked files:
- Private key — stays on your machine, never shared
- Public key — uploaded to GitHub, used to verify you
When you attempt a connection, GitHub sends a challenge that only your private key can solve. If it matches the public key on file, access is granted. No password required.
This is meaningfully more secure than HTTPS with a password, and it's the standard approach for developers who work with Git regularly.
What You'll Need Before You Start
- A terminal (macOS/Linux have one built in; Windows users can use Git Bash, WSL, or PowerShell with OpenSSH)
- A GitHub account
- Git installed on your machine
Step 1: Check for Existing SSH Keys 🔑
Before generating a new key, check whether one already exists on your system: