How to Add SSH Keys to Your GitHub Account

In this article, we will explain how to add SSH keys to your GitHub Account.

Adding SSH keys to your GitHub account allows you to securely connect to repositories without entering your username and password each time.

Let us follow the guide:

  1. Open your terminal (Linux/macOS) or Git Bash (Windows).
  2. Run the following command to see if you already have an SSH key:
    ls -al ~/.ssh
  3. Look for files named ‘id_rsa.pub’ or ‘id_ed25519.pub’. If present, you can use them; otherwise, proceed to generate a new key.
  4. Generate a new SSH key by running:
    ssh-keygen -t ed25519 -C “[email protected]

    If your system doesn’t support ed25519, use:

    ssh-keygen -t rsa -b 4096 -C “[email protected]
  5. When prompted to “Enter a file in which to save the key,” press Enter to accept the default.
  6. Add a passphrase if you want extra security (optional).
  7. Start the SSH agent by running:
    eval “$(ssh-agent -s)”
  8. Add your key to the agent:
    ssh-add ~/.ssh/id_ed25519

    Replace ‘id_ed25519’ with your key filename if different.

  9. Copy your public key to the clipboard:
    cat ~/.ssh/id_ed25519.pub
  10. Copy the full output (starts with ssh-ed25519 or ssh-rsa).
  11. Log in to your GitHub account.
  12. Go to ‘Settings>SSH and GPG keys>New SSH key’.
  13. Give your key a descriptive Title (e.g., “Work Laptop”).
  14. Paste your public key into the ‘Key’ field.
  15. Click ‘Add SSH key’.
  16. Test your SSH connection by running:
    ssh -T [email protected]

    You should see a message like:
    Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.

In this manner, adding SSH keys to GitHub improves security and makes working with repositories faster and more convenient. Make sure to keep your private keys safe and never share them.

Visit our Knowledge Base to learn how to change the SSH Port in Red Hat Enterprise Linux.

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

Restoring vhost Folder Content via CLI: A Step-by-Step Guide

This tutorial is applicable for only Parallels Plesk Panel 10.x for Linux If you need…

How To Change PHP Settings or Parameter Manually Through Plesk Obsidian?

This topic shows how Plesk users can use the Customer Panel to manage PHP settings…

How to utilize Google’s free SMTP server?

Google’s Gmail provides a free SMTP server, it can be utilizing by anybody who has…