SSH Keys for GitHub (2024)

Objectives

  • Explain what an SSH key is
  • Generate your own SSH key pair
  • Add your SSH key to your GitHub account
  • Learn how to use your SSH key in your GitHub workflow

Why Use an SSH Key?

When working with a GitHub repository, you'll often need to identify yourself to GitHub using your username and password. An SSH key is an alternate way to identify yourself that doesn't require you to enter you username and password every time.

SSH keys come in pairs, a public key that gets shared with services like GitHub, and a private key that is stored only on your computer. If the keys match, you're granted access.

The cryptography behind SSH keys ensures that no one can reverse engineer your private key from the public one.

Generating an SSH key pair

The first step in using SSH authorization with GitHub is to generate your own key pair.

You might already have an SSH key pair on your machine. You can check to see if one exists by moving to your .ssh directory and listing the contents.

$ cd ~/.ssh$ ls

If you see id_rsa.pub, you already have a key pair and don't need to create a new one.

If you don't see id_rsa.pub, use the following command to generate a new key pair. Make sure to replace your@email.com with your own email address.

$ ssh-keygen -o -t rsa -C "your@email.com"

(The -o option was added in 2014; if this command fails for you, just remove the -o and try again)

When asked where to save the new key, hit enter to accept the default location.

Generating public/private rsa key pair.Enter file in which to save the key (/Users/username/.ssh/id_rsa):

You will then be asked to provide an optional passphrase. This can be used to make your key even more secure, but for this lesson you can skip it by hitting enter twice.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

When the key generation is complete, you should see the following confirmation:

Your identification has been saved in /Users/username/.ssh/id_rsa.Your public key has been saved in /Users/username/.ssh/id_rsa.pub.The key fingerprint is:01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your@email.comThe key's randomart image is:+--[ RSA 2048]----+| || || . E + || . o = . || . S = o || o.O . o || o .+ . || . o+.. || .+=o |+-----------------+

The random art image is an alternate way to match keys but we won't be needing this.

Add your public key to GitHub

We now need to tell GitHub about your public key. Display the contents of your new public key file with cat:

$ cat ~/.ssh/id_rsa.pub

The output should look something like this:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA879BJGYlPTLIuc9/R5MYiN4yc/YiCLcdBpSdzgK9Dt0Bkfe3rSz5cPm4wmehdE7GkVFXrBJ2YHqPLuM1yx1AUxIebpwlIl9f/aUHOts9eVnVh4NztPy0iSU/Sv0b2ODQQvcy2vYcujlorscl8JjAgfWsO3W4iGEe6QwBpVomcME8IU35v5VbylM9ORQa6wvZMVrPECBvwItTY8cPWH3MGZiK/74eHbSLKA4PY3gM4GHI450Nie16yggEg2aTQfWA1rry9JYWEoHS9pJ1dnLqZU3k/8OWgqJrilwSoC5rGjgp93iu0H8T6+mEHGRQe84Nk1y5lESSWIbn6P636Bl3uQ== your@email.com

Copy the contents of the output to your clipboard.

Login to github.com and bring up your account settings by clicking the tools icon.

SSH Keys for GitHub (1)

Select SSH Keys from the side menu, then click the Add SSH key button.

SSH Keys for GitHub (2)

Name your key something whatever you like, and paste the contents of your clipboard into the Key text box.

SSH Keys for GitHub (3)

Finally, hit Add key to save. Enter your github password if prompted.

####Using Your SSH Key

Going forward, you can use the SSH clone URL when copying a repo to your local machine.

SSH Keys for GitHub (4)

This will allow you to bypass entering your username and password for future GitHub commands.

Key Points

  • SSH is a secure alternative to username/password authorization
  • SSH keys are generated in public / private pairs. Your public key can be shared with others. The private keys stays on your machine only.
  • You can authorize with GitHub through SSH by sharing your public key with GitHub.
SSH Keys for GitHub (2024)
Top Articles
Best-selling book
Titan: Members-Only Wealth Platform
Asist Liberty
Fredatmcd.read.inkling.com
What is Mercantilism?
Winston Salem Nc Craigslist
Celebrity Extra
What happened to Lori Petty? What is she doing today? Wiki
Tj Nails Victoria Tx
Heska Ulite
Urban Dictionary Fov
978-0137606801
Who called you from 6466062860 (+16466062860) ?
Craigslist Edmond Oklahoma
Nissan Rogue Tire Size
Check From Po Box 1111 Charlotte Nc 28201
Rams vs. Lions highlights: Detroit defeats Los Angeles 26-20 in overtime thriller
Dirt Removal in Burnet, TX ~ Instant Upfront Pricing
Missouri Highway Patrol Crash
Veracross Login Bishop Lynch
Between Friends Comic Strip Today
Ice Dodo Unblocked 76
Xfinity Cup Race Today
Rs3 Ushabti
Fleet Farm Brainerd Mn Hours
Kohls Lufkin Tx
Meet the Characters of Disney’s ‘Moana’
UCLA Study Abroad | International Education Office
Housing Intranet Unt
Page 2383 – Christianity Today
Ridge Culver Wegmans Pharmacy
October 19 Sunset
Unm Hsc Zoom
15 Downer Way, Crosswicks, NJ 08515 - MLS NJBL2072416 - Coldwell Banker
Watchdocumentaries Gun Mayhem 2
Mississippi State baseball vs Virginia score, highlights: Bulldogs crumble in the ninth, season ends in NCAA regional
Skyrim:Elder Knowledge - The Unofficial Elder Scrolls Pages (UESP)
Panorama Charter Portal
Sas Majors
How to Quickly Detect GI Stasis in Rabbits (and what to do about it) | The Bunny Lady
Craigs List Hartford
Ds Cuts Saugus
Advance Auto.parts Near Me
Erica Mena Net Worth Forbes
Mlb Hitting Streak Record Holder Crossword Clue
Every Type of Sentinel in the Marvel Universe
Bbwcumdreams
Google Flights Missoula
Rocket Bot Royale Unblocked Games 66
Dmv Kiosk Bakersfield
Tenichtop
Mazda 3 Depreciation
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 5900

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.