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.


This content originally appeared on DEV Community and was authored by Ashen Chathuranga

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

  1. Log in to your GitHub account.
  2. Go to Settings > SSH and GPG Keys.
  3. Click New SSH Key.
  4. Provide a title (e.g., "Laptop SSH Key").
  5. Paste the public key from your clipboard into the Key field.
  6. 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 content originally appeared on DEV Community and was authored by Ashen Chathuranga


Print Share Comment Cite Upload Translate Updates
APA

Ashen Chathuranga | Sciencx (2025-01-16T11:35:21+00:00) Setting Up GitHub SSH Keys on Your Computer. Retrieved from https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/

MLA
" » Setting Up GitHub SSH Keys on Your Computer." Ashen Chathuranga | Sciencx - Thursday January 16, 2025, https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/
HARVARD
Ashen Chathuranga | Sciencx Thursday January 16, 2025 » Setting Up GitHub SSH Keys on Your Computer., viewed ,<https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/>
VANCOUVER
Ashen Chathuranga | Sciencx - » Setting Up GitHub SSH Keys on Your Computer. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/
CHICAGO
" » Setting Up GitHub SSH Keys on Your Computer." Ashen Chathuranga | Sciencx - Accessed . https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/
IEEE
" » Setting Up GitHub SSH Keys on Your Computer." Ashen Chathuranga | Sciencx [Online]. Available: https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/. [Accessed: ]
rf:citation
» Setting Up GitHub SSH Keys on Your Computer | Ashen Chathuranga | Sciencx | https://www.scien.cx/2025/01/16/setting-up-github-ssh-keys-on-your-computer/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.