Skip to content

Instantly share code, notes, and snippets.

@smith558
Last active October 9, 2023 11:04
Show Gist options
  • Save smith558/947d15ac8ee1879077b09c95c72b9dc7 to your computer and use it in GitHub Desktop.
Save smith558/947d15ac8ee1879077b09c95c72b9dc7 to your computer and use it in GitHub Desktop.
Generate SSH key on Ubuntu

Here's a simplified guide to generate an SSH key on Ubuntu and link it with Git and a GitHub profile:

  1. Generate SSH Key:

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

    When prompted, press Enter to accept the default file path and filename.

  2. Start the SSH Agent and Add Your Key:

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
  3. Display the SSH Key:

    cat ~/.ssh/id_rsa.pub

    This will display your public SSH key in the terminal. Manually select the content and copy it using your mouse or terminal's copy function.

  4. Link SSH Key to GitHub:

    • Go to GitHub and log into your account.
    • Click on your profile picture in the top right corner, and then click on Settings.
    • In the left sidebar, click on SSH and GPG keys.
    • Click the New SSH key button.
    • Paste your copied SSH key into the "Key" field.
    • Give it a meaningful title and then click Add SSH key.
  5. Test the Connection:

    ssh -T git@github.com

    If everything went well, you should see a message saying that you've successfully authenticated.

  6. Configure Git (if not done before):

    git config --global user.name "Your Name"
    git config --global user.email "your_email@example.com"

That's it! You've generated an SSH key on Ubuntu, linked it to Git, and associated it with your GitHub profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment