Git Toolbox

// Git Toolbox

SSH key setup

Push and pull without typing a password: create an SSH key and add it to your Git host, step by step.

System
Host

Two files are created: id_ed25519 (private, never share it) and id_ed25519.pub (public, the one you paste on the website).

  1. 1

    Check for an existing key

    If you see id_ed25519 and id_ed25519.pub, you already have a key: skip to step 3.

    Safe
    $ Get-ChildItem $HOME/.ssh
  2. 2

    Generate a new key

    Ed25519 is the modern, recommended type. Press Enter to keep the default file, and choose a passphrase: it protects the key if your computer is stolen. If a key already exists at this path, answer “n” to keep it.

    Caution
    $ ssh-keygen -t ed25519 -C "you@example.com"
  3. 3

    Start the SSH agent (PowerShell as administrator)

    The agent remembers your passphrase. These two lines only need to be run once, in an administrator PowerShell.

    Caution
    $ Get-Service ssh-agent | Set-Service -StartupType Automatic
    $ Start-Service ssh-agent
  4. 4

    Add the key to the agent

    In a normal PowerShell.

    Safe
    $ ssh-add $HOME/.ssh/id_ed25519
  5. 5

    Copy the PUBLIC key

    Only the .pub file. The other one (without .pub) is your private key: never share it, never commit it.

    Safe
    $ Get-Content $HOME/.ssh/id_ed25519.pub | Set-Clipboard
  6. 6

    Add it to GitHub

    Safe

    Paste the key, give it a name you'll recognise (e.g. “Work laptop”), save.

    Open GitHub SSH settings
  7. 7

    Test the connection

    The first time, confirm the server fingerprint with “yes”. You should get a greeting with your username.

    Safe
    $ ssh -T git@github.com
  8. 8

    Switch an existing repository to SSH

    Only for repositories cloned with an https:// URL. Replace OWNER/REPO.

    Caution
    $ git remote set-url origin git@github.com:OWNER/REPO.git
    $ git remote -v