Setting Up GitHub SSH Keys on Your Computer
This guide provides step-by-step instructions to set up SSH keys for secure and efficient interaction with GitHub repositories. Prerequisites Ensure Git is installed on your system. If not, download and install it from Git for Windows. A GitHub account. Steps to Set Up SSH Keys 1. Configure Git with Your User Information Run the following commands to set your Git username and email address globally. Replace Your Name and your_email@example.com with your details. git config --global user.name "Your Name" git config --global user.email "your_email@example.com" 2. Generate an SSH Key Pair Use the ssh-keygen command to generate a new SSH key pair. Replace your_email@example.com with your GitHub email address. ssh-keygen -t ed25519 -C "your_email@example.com" When prompted for a file location, press Enter to accept the default: /c/Users/YOU/.ssh/id_ed25519. Optionally, set a passphrase for added security. 3. Start the SSH Agent Enable and start the SSH agent to manage your SSH keys. Use the following commands in PowerShell (run as Administrator): Get-Service -Name ssh-agent | Set-Service -StartupType Manual Start-Service ssh-agent 4. Add Your SSH Key to the Agent Add the generated private key to the SSH agent for authentication. ssh-add c:/Users/YOU/.ssh/id_ed25519 Replace YOU with your system username if necessary. 5. Copy the Public Key to Your Clipboard Copy the contents of your public key file to your clipboard for adding it to GitHub: clip < ~/.ssh/id_ed25519.pub 6. Add the SSH Key to GitHub Log in to your GitHub account. Go to Settings > SSH and GPG Keys. Click New SSH Key. Provide a title (e.g., "Laptop SSH Key"). Paste the public key from your clipboard into the Key field. Click Add SSH Key. 7. Verify the SSH Connection Run the following command to confirm the connection with GitHub: ssh -T git@github.com If successful, you will see a message similar to: Hi username! You've successfully authenticated, but GitHub does not provide shell access. Conclusion Your SSH key is now configured for GitHub. You can securely push, pull, and manage your repositories without entering your GitHub credentials repeatedly.
This guide provides step-by-step instructions to set up SSH keys for secure and efficient interaction with GitHub repositories.
Prerequisites
- Ensure Git is installed on your system. If not, download and install it from Git for Windows.
- A GitHub account.
Steps to Set Up SSH Keys
1. Configure Git with Your User Information
Run the following commands to set your Git username and email address globally. Replace Your Name
and your_email@example.com
with your details.
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
2. Generate an SSH Key Pair
Use the ssh-keygen
command to generate a new SSH key pair. Replace your_email@example.com
with your GitHub email address.
ssh-keygen -t ed25519 -C "your_email@example.com"
- When prompted for a file location, press Enter to accept the default:
/c/Users/YOU/.ssh/id_ed25519
. - Optionally, set a passphrase for added security.
3. Start the SSH Agent
Enable and start the SSH agent to manage your SSH keys. Use the following commands in PowerShell (run as Administrator):
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent
4. Add Your SSH Key to the Agent
Add the generated private key to the SSH agent for authentication.
ssh-add c:/Users/YOU/.ssh/id_ed25519
Replace YOU
with your system username if necessary.
5. Copy the Public Key to Your Clipboard
Copy the contents of your public key file to your clipboard for adding it to GitHub:
clip < ~/.ssh/id_ed25519.pub
6. Add the SSH Key to GitHub
- Log in to your GitHub account.
- Go to Settings > SSH and GPG Keys.
- Click New SSH Key.
- Provide a title (e.g., "Laptop SSH Key").
- Paste the public key from your clipboard into the Key field.
- Click Add SSH Key.
7. Verify the SSH Connection
Run the following command to confirm the connection with GitHub:
ssh -T git@github.com
If successful, you will see a message similar to:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Conclusion
Your SSH key is now configured for GitHub. You can securely push, pull, and manage your repositories without entering your GitHub credentials repeatedly.