📄 Copy-Paste SSH registration list - Reader

I keep this content for myself. I notice that I have been repeating this process, so want to follow this for myself and anyone I need to advise/guide later.

To create an SSH key and register it with GitHub, follow these steps:


Step 1: Check for Existing SSH Keys

Before creating a new SSH key, check if you already have one:

  1. Open a terminal (Linux/Mac) or Git Bash (Windows).
  2. Run the following command to check for existing SSH keys:
    ls -al ~/.ssh
    

    Look for files like id_rsa and id_rsa.pub or id_ed25519 and id_ed25519.pub. If they exist, you can use them or create a new one.


Step 2: Generate a New SSH Key

If you don’t have an SSH key or want to create a new one:

  1. Run the following command (replace your_email@example.com with your GitHub email):
    ssh-keygen -t ed25519 -C "your_email@example.com"
    
    • If your system doesn’t support ed25519, use:
      ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
      
  2. When prompted to “Enter a file in which to save the key,” press Enter to accept the default location.

  3. Optionally, set a passphrase for added security. You can press Enter to skip this step.

Step 3: Add the SSH Key to the SSH Agent

  1. Start the SSH agent:
    eval "$(ssh-agent -s)"
    
  2. Add your SSH private key to the agent:
    ssh-add ~/.ssh/id_ed25519
    

    (If you used rsa, replace id_ed25519 with id_rsa.)


Step 4: Copy the SSH Public Key

  1. Copy the contents of your public key to the clipboard:
    cat ~/.ssh/id_ed25519.pub
    

    (Or id_rsa.pub if you used RSA.)

  2. Highlight the output and copy it.

Step 5: Add the SSH Key to GitHub

  1. Go to GitHub and log in to your account.
  2. Click on your profile picture in the top-right corner and select Settings.
  3. In the left sidebar, click SSH and GPG keys.
  4. Click the New SSH key button.
  5. Give the key a title (e.g., “My Laptop”).
  6. Paste the copied public key into the “Key” field.
  7. Click Add SSH key.

Step 6: Test the SSH Connection

  1. Run the following command to test the connection:
    ssh -T git@github.com
    
  2. If successful, you’ll see a message like:
    Hi username! You've successfully authenticated, but GitHub does not provide shell access.
    

Step 7: Use SSH with GitHub

Now you can use SSH to interact with GitHub repositories. For example:

  • Clone a repository using SSH:
    git clone git@github.com:username/repository.git
    
  • Set the remote URL of an existing repository to use SSH:
    git remote set-url origin git@github.com:username/repository.git
    

That’s it! You’ve successfully created an SSH key and registered it with GitHub. 🎉

Keep reading

More in Engineering

  1. Engineering Fundamentals for Agent Programming

    · 4 min read

    What I set up so agents can write all my code and I can review less: a clean codebase, real verification, written-down domain knowledge, and auto-merge for the PRs that earn it.

  2. AI Coding: Programming by Coincidence at Scale

    · 2 min read

    AI lets us pile up code we don't understand faster than ever. Working code is not correct code.

  3. Keycloak Components: Roles, Scopes, Client Scopes, and Audience

    · 8 min read

    AI-researched

    A simple explanation of how Keycloak controls access from an app to an SSH MCP server.

  4. Attention has four matrices, not three

    · 13 min read

    AI-researched

    Q, K, V, and the output projection the name leaves out. What each weight does to the same input, and why the differences between them decide what an inference server has to cache.

📂 All 14 posts in Engineering