How to Set Up RSA Key and GitHub Connection: A Step-by-Step Guide

How to Set Up RSA Key and GitHub Connection: A Step-by-Step Guide

April 2025

In this vlog, we'll guide you through the process of setting up an RSA SSH key and connecting it to GitHub. This will allow you to securely interact with your GitHub repositories without having to enter your password every time. Let's dive into the process!

Step 1: Generate a New RSA SSH Key 🔑

The first step is to generate an RSA SSH key on your machine. This key will act as a secure digital signature that GitHub will use to verify your identity. You can do this by using the `ssh-keygen` command in your terminal.

Command to Generate RSA Key

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Step 2: Add the SSH Key to the SSH Agent 👨‍💻

Now that your SSH key is generated, you need to add it to the SSH agent, which manages the authentication for you. Use the following commands to start the SSH agent and add your key.

Start SSH Agent and Add Key

eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa

Step 3: Add SSH Key to GitHub 🖇️

Next, you need to add the public SSH key to your GitHub account. First, you need to copy the public key that was generated in the previous step. You can do this with the command below, which will output your public key to the terminal.

Copy the SSH Public Key

cat ~/.ssh/id_rsa.pub
Image description

Step 4: Add the Key to Your GitHub Account 🔑🖥️

Once you have the public key copied, follow these steps to add it to your GitHub account: 1. Open GitHub and go to your profile settings. 2. Click on 'SSH and GPG keys' on the left sidebar. 3. Click on 'New SSH key'. 4. Paste the copied SSH key into the key field and give it a title. 5. Click 'Add SSH key'.

GitHub SSH Key Setup


    # In GitHub, click on:
    # Settings → SSH and GPG Keys → New SSH key
    # Paste the copied key and save it.
    

Step 5: Test the SSH Connection 🚀

Now that your SSH key is set up and linked to GitHub, it's time to test the connection. Run the following command in your terminal to confirm that the authentication is working correctly.

Test GitHub Connection

ssh -T git@github.com

Step 6: Git Push Without Password ⚙️

Once your SSH connection is working, you can push to your GitHub repositories without having to enter your GitHub password every time. Use the following command to push changes to your repository.

Push Code to GitHub

git push origin main

Conclusion: Secured and Hassle-Free GitHub Interaction 🔒

Setting up an RSA key for GitHub is a simple yet powerful way to ensure secure interactions with your repositories. Once the setup is done, you'll be able to work seamlessly with GitHub without having to constantly input your credentials.

Author

Arjun Singh
      📨 arjuns.dev25@gmail.com