Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of adding SSH keys to GitHub?

Tags:

git

github

ssh

I am reading through a book that had me generate an SSH key and add it to GitHub. After doing so, the book simply states that we are ready to create a repository and push our code up. I am confused because I have never needed to do this to push up my code. So what purpose does this serve?

like image 786
tiller1010 Avatar asked Sep 12 '25 20:09

tiller1010


2 Answers

Keys are basically decoupled passwords. Typically, there is a one-to-one mapping between passwords and accounts: each account has exactly one password, and each password is (or rather, should be) used with exactly one account.

However, any number of keys can be associated with a single account. This means you can have a different way of authenticating yourself from your personal computer, your work computer, your phone, your tablet, etc. If any one of those keys gets compromised, you can invalidate it without affecting the others.

This also allows for more secure account sharing: multiple maintainers can each have their own key for contributing to a shared repository.

like image 150
chepner Avatar answered Sep 14 '25 08:09

chepner


The ssh key generated lets github verify you are the one pushing code and not someone else who might be malicious or otherwise. They are less cumbersome and more secure than manually entering a username/password as well. I'm not sure how you previously used github but SSH keys are best practice way to secure your repo so I would recommend you continue to use this key in the future.

like image 39
jamesfranco Avatar answered Sep 14 '25 08:09

jamesfranco