MirrorNest
← All guides

Git + SSH key authentication setup

Install Git and generate an SSH key pair for authenticating with GitHub/GitLab/Bitbucket without typing a password on every push.

Target: Windows / MacOS / LinuxDevelopmentVersion ControlOfficial homepage ↗Official docs ↗
This guide is synthesized from Git + SSH key authentication setup's own official documentation, linked above — always cross-check exact package/version names there before running these commands on a production server, since distro and project versions move over time.
  1. 1Install Git

    # Windows winget install --id Git.Git -e
    # MacOS brew install git
    # Ubuntu/Debian sudo apt install git
  2. 2Set your name and email

    These appear on every commit you make -- use the same email as your GitHub/GitLab account so commits link to your profile.

    git config --global user.name "Your Name"
    git config --global user.email "[email protected]"
  3. 3Generate an SSH key pair

    ssh-keygen -t ed25519 -C "[email protected]"

    Press Enter to accept the default file location. Ed25519 is the modern, recommended key type -- use `-t rsa -b 4096` only if a specific service requires RSA.

  4. 4Add the key to the SSH agent

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519
  5. 5Copy the public key and add it to your Git host

    Paste the copied key into GitHub/GitLab/Bitbucket's SSH keys settings page, then verify:

    # MacOS pbcopy < ~/.ssh/id_ed25519.pub
    # Windows (PowerShell) Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard
    # Linux cat ~/.ssh/id_ed25519.pub
  6. 6Test the connection