Skip to content

Using SSH Keys with Git & Git Providers

Prerequisites

Assumptions & Prerequisites

This guide assumes you are using one of the following operating systems:

  • macOS: Monterey (12) or newer. These versions use zsh as the default shell.
  • Windows: Windows 10 (build 1809) or newer versions.
  • Linux: A distribution that uses bash.

On all of these systems, this guide assumes you have Git installed and configured. If you have not done so, please refer to the Git Installation Guide.

This guide also assumes that you will be using OpenSSH. OpenSSH comes installed on Windows 11, macOS, and most Linux distributions.

If you are using Windows 10, follow this guide to install OpenSSH on Windows 10.

Check whether your system qualifies on macOS or Linux by running the following command in your terminal:

ps -o comm= -p $$

If the output is zsh, then you are using a macOS system that qualifies for this guide. If the output is bin/bash, then you are using a Linux system that qualifies for this guide.

Introduction

This guide will walk you through the process of using SSH keys with Git and Git providers. SSH keys provide a secure way to authenticate with Git providers.

Step 1: Check for Existing SSH Keys or Generate a New One

The first step is to:

  1. Check for existing SSH keys on your system.
  2. If you don't have any, you will need to generate a new SSH key.

Step 2: Save Your SSH Keys to the SSH Agent

  1. Setting up your SSH Agent.
  2. Load your SSH key into your SSH Agent.

Step 3: Add Your SSH Keys to a Git Provider

  1. Using SSH Keys with Git Providers

Step 4: Configure Your Git Repository

  1. Configuring your Git repository to use your SSH key