Setting Up SSH Keys for GitHub

SSH keys let GitHub know it is you, without typing your password every time.

Do this once on each machine you use for class:

  • JupyterHub terminal
  • your laptop terminal
  • a lab machine terminal

Some screenshots below are from JupyterHub, but the same commands work in any terminal.

When should I do this?

Do this before cloning/pushing course repos.

Why SSH instead of HTTPS?

  • Fewer login prompts
  • Works smoothly in JupyterHub and terminal workflows
  • Common setup in CS courses and real projects

Steps

  1. Open a terminal.

    JupyterHub terminal example

  2. Make a key:

    ssh-keygen
    

    Press Enter for each prompt (file location + passphrase) if you want the default setup.

    Running ssh-keygen in terminal ssh-keygen output example

  3. Check that keys were created:

    ls ~/.ssh
    

    You should see at least:

    id_ed25519
    id_ed25519.pub
    
  4. Show your public key:

    cat ~/.ssh/id_ed25519.pub
    

    Copy the full line.

  5. In GitHub, go to Settings.

    GitHub profile menu with Settings

  6. Open SSH and GPG keys.

    GitHub SSH and GPG keys sidebar item

  7. Click New SSH key and paste your public key.

    • Title: use something clear like jupyterhub or my-laptop
    • Key type: Authentication Key

    GitHub add new SSH key form

Quick troubleshooting

  • Permission denied (publickey): Key was not added to GitHub, or wrong GitHub account is logged in.
  • Remote starts with https://: Switch to SSH remote.
  • No ~/.ssh folder: Run ssh-keygen first.
  • Copied wrong file: Copy id_ed25519.pub, not id_ed25519.

Important

Never share your private key (~/.ssh/id_ed25519).

Only copy/share the public key (~/.ssh/id_ed25519.pub).