GitHub SSH Key How To Setup Guide Secure Connection

Logan Jul 13, 2026

Are you tired of having to type your GitHub password every time you need to push changes to your repository? SSH keys offer a secure and convenient way to authenticate with GitHub. In this guide, we'll walk you through the process of generating and adding SSH keys to your GitHub account.

🔐 GitHub SSH Setup: Secure & Streamline Your Workflow
🔐 GitHub SSH Setup: Secure & Streamline Your Workflow

Before we dive in, ensure that you have Git installed on your computer. You can download and install Git from the official Git website.

#4:How to Create and add SSH Key to GitHub | How to Generate SSH Keys in Git | GitHub Tutorial
#4:How to Create and add SSH Key to GitHub | How to Generate SSH Keys in Git | GitHub Tutorial

Generating SSH Key Pairs

First, we need to generate a new SSH key pair on your local machine. Open your terminal or command prompt and type the following command:

How to Secure Github Access With an SSH Key - Make Tech Easier
How to Secure Github Access With an SSH Key - Make Tech Easier

ssh-keygen -t ed25519 -C "your_email@example.com"

Understanding the Command

Streamlined Guide: Setting Up SSH and GPG Keys on GitHub
Streamlined Guide: Setting Up SSH and GPG Keys on GitHub

Here's what the command does:

  • ssh-keygen - Invokes the SSH key generation utility.
  • -t ed25519 - Specifies the type of key to generate. Ed25519 is a fast and secure key type.
  • -C "your_email@example.com" - Sets a comment/label for the key, which is useful for identifying it later.

Saving and Naming Your Key

The Ultimate GitHub SSH Key Tutorial (Fast & Easy)
The Ultimate GitHub SSH Key Tutorial (Fast & Easy)

When prompted, choose a file location to save your key. By default, it will be saved in ~/.ssh/id_ed25519. You can also add a passphrase for an extra layer of security. Make sure to remember this passphrase!

Adding SSH Key to GitHub

Now that we have our SSH key pair, let's add it to GitHub. First, add the public key to the SSH agent:

How to Connect Git and Github with SSH Keys 2024?
How to Connect Git and Github with SSH Keys 2024?

eval "$(ssh-agent -s)"

ssh-add ~/.ssh/id_ed25519

Setting up SSH Keys for Github, GitLab, and Bitbucket in one windows pc
Setting up SSH Keys for Github, GitLab, and Bitbucket in one windows pc
Ssh Public Key for Github and Bitbucket
Ssh Public Key for Github and Bitbucket
SSH keys and how to use them with GitHub (and why)
SSH keys and how to use them with GitHub (and why)
Add a SSH Key to Github
Add a SSH Key to Github
🔐 GitHub Access & Authentication Settings: Secure Your Account
🔐 GitHub Access & Authentication Settings: Secure Your Account
⚙️ Git & GitHub Initial Settings: Quick Setup Guide
⚙️ Git & GitHub Initial Settings: Quick Setup Guide
a computer screen with the words git commands in black and white, on it
a computer screen with the words git commands in black and white, on it
SSH Troubleshooting Guide for Linux Admins | Fix 13 Common SSH Errors
SSH Troubleshooting Guide for Linux Admins | Fix 13 Common SSH Errors
an image of a poster with words in the background that say, github doks for finding files
an image of a poster with words in the background that say, github doks for finding files
Leaked keys from GitHub
Leaked keys from GitHub
GitHub - tillitis/tkey-ssh-agent: SSH Agent for TKey, the flexible open hardware/software USB security key 🔑
GitHub - tillitis/tkey-ssh-agent: SSH Agent for TKey, the flexible open hardware/software USB security key 🔑
How to Authenticate Your Git to GitHub with SSH Keys
How to Authenticate Your Git to GitHub with SSH Keys
🖥️ Git & GitHub Setup on Windows: Essential Tools & Configuration
🖥️ Git & GitHub Setup on Windows: Essential Tools & Configuration
the github chat sheet is displayed in pink and black
the github chat sheet is displayed in pink and black
Anton (@therceman) on X
Anton (@therceman) on X
Installing a theme from a private Git repository
Installing a theme from a private Git repository
Recovering your SSH key passphrase - GitHub Docs
Recovering your SSH key passphrase - GitHub Docs
🐧 Git & GitHub Setup on Linux & Remote Servers: Essential Guide
🐧 Git & GitHub Setup on Linux & Remote Servers: Essential Guide
Arch Linux, Black Arch Linux, Linux Customization, Kali Linux Commands, Kali Linux, Hacking Books, Data Science Learning, Learn Computer Coding, Secret Websites
Arch Linux, Black Arch Linux, Linux Customization, Kali Linux Commands, Kali Linux, Hacking Books, Data Science Learning, Learn Computer Coding, Secret Websites
the git chatsheet screen is lit up with orange and green text on it
the git chatsheet screen is lit up with orange and green text on it

Displaying Public Key

Copy the public key content:

pbcopy < ~/.ssh/id_ed25519.pub

Pasting Public Key to GitHub

Go to your GitHub profile, click on "Settings", then "SSH and GPG keys". Click on "New SSH key", give it a title, and paste the key content in the "Key" field. Click "Add key" to save it.

Now, you can use the ssh -T git@github.com command to verify that your SSH key is working. You should see a "Success" message. Finally, configure Git to use your SSH key for authentication:

git config --global user.name "Your Name"

git config --global user.email "your_email@example.com"

You're all set! From now on, you can push changes to your GitHub repositories using SSH keys. Happy coding!