Skip to content

Instantly share code, notes, and snippets.

@ianmstew
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianmstew/a240726f111f335220ba to your computer and use it in GitHub Desktop.
Save ianmstew/a240726f111f335220ba to your computer and use it in GitHub Desktop.
Enabling key-based Github access

Reference: https://help.github.com/articles/generating-ssh-keys/

  1. Make sure you have an SSH key for your development machine.

    # Confirm that "~/.ssh" exists and you see "id_rsa" and "id_rsa.pub" inside it
    ls ~/.ssh/
    
    # If .ssh doesn't exist or does not contain id_rsa/id_rsa.pub, then generate them:
    ssh-keygen -t rsa -C "your_email@example.com"
    > Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
    > Enter passphrase (empty for no passphrase): [Type a passphrase]
    > Enter same passphrase again: [Type passphrase again]
    
    # Add generated key to your SSH Agent
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
    > [Enter key passphrase to install it]
  2. Add dev machine SSH key to your Github account, if you haven't already.

  3. Copy your public key to the clipboard: pbcopy < ~/.ssh/id_rsa.pub

  4. Sign into Github from your browser

  5. Go to Settings (gear icon) -> SSH keys Github SSH key panel

  6. Click "Add SSH Key"

  7. Name your key anything you want

  8. Paste your public key into the "Key" box

  9. Click "Add key"

  10. Confirm your key-based Github access

    # The following command should trigger the response below
    ssh -T git@github.com
    > Hi <github user name>! You've successfully authenticated, but GitHub does not provide shell access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment