A quick guide to setting up SSH Keys & adding them to GitHub

Dev Tools

November 14, 2023

A quick guide to setting up SSH Keys & adding them to GitHub

Enhancing your security when accessing your GitHub repositories can be efficiently done by setting up an SSH key. This guide will walk you through the steps to create an SSH key on Mac, Windows, and Linux systems and add it to your GitHub account.

Check for Existing SSH Keys

  • Open a terminal.
  • Run

    Loading...

    to see if existing SSH keys are present.

Generate a New SSH Key

  • Run

    Loading...

    to generate a new SSH key, replacing "your_email@example.com" with your GitHub email address.

Add SSH Key to the SSH-Agent

  • Start the

    Loading...

    in the background with eval "$(ssh-agent -s)".
  • If you are using macOS Sierra 10.12.2 or later, you need to modify

    Loading...

    to automatically load keys into the ssh-agent and store passphrases in your keychain. If the file doesn't exist, create it with touch

    Loading...

    and open it with your favorite editor.
  • Add the following to

    Loading...

Loading...

Add the SSH Key to Your GitHub Account

  • Copy the SSH public key to your clipboard with

    Loading...

    .
  • Go to GitHub and under your profile settings, find the SSH and GPG keys section.
  • Click “New SSH Key”, paste your key, and save it.

For Windows Users

Install Git for Windows

  • Download Git from git-scm.com.
  • During installation, make sure to select Git Bash and the option to "Use Git from the Windows Command Prompt".

Generate a New SSH Key

  • Open Git Bash.
  • Run

    Loading...

    .

Add SSH Key to the SSH-Agent

  • Ensure the ssh-agent is running:

    Loading...

    .
  • Add your SSH key to the ssh-agent:

    Loading...

    .

Add the SSH Key to Your GitHub Account

  • Copy the SSH public key by opening the file

    Loading...

    with a text editor and copying its content.
  • Follow the same GitHub instructions as for Mac/Linux to add your SSH key to your GitHub account.

Saving SSH Config

  • For all operating systems, you may want to set up an SSH config file:
  • Create or edit

    Loading...

    and add configurations for the hosts you connect to, such as:

Loading...

These steps will set up your SSH keys across different operating systems and add them to your GitHub account. This setup allows for a secure connection to GitHub without repeatedly entering your credentials. Always handle your private key with care and never disclose it. Happy coding securely!

** Book Recommendation: Version Control with Git ** Powerful Tools and Techniques for Collaborative Software Development

** Book Recommendation: Pragmatic Programmer ** Your journey to mastery

Join Our Discord Community Unleash your potential, join a vibrant community of like-minded learners, and let's shape the future of programming together. Click here to join us on Discord.

For Consulting and Mentorship, feel free to contact slavo.io

©2024. All rights reserved. Designed by Prototype.NEXT

slavo.io software development - Consultingslavo.io software development - Consulting slavo.io software development - Consulting