How do you authenticate on github

If you need help with something, this is the place to be.
Post Reply
zenith
Posts: 1
Joined: Thu Aug 03, 2023 10:49 pm

How do you authenticate on github

Post by zenith »

Could someone provide an explanation how GitHub authentication should be managed? Should one choose ssh key or personal access token, if the latter should one opt for a fine-grained or a classic token? Moreover, is there a method to store the token to avoid rewriting it every time you for example push to the repository? (I am using git cli not the desktop windows program)
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How do you authenticate on github

Post by MattKC »

I have a classic token which works fine, though my understanding is "fine-grained" tokens are considered safer/more secure since they provide much more control over exactly what the token has access to (i.e. how much is at risk if it falls into the wrong hands). For example, fine-grained tokens let you use different tokens for different repositories so if one gets compromised the others are still safe. But if you're not concerned about any of that, classic token should be fine.

There is a way to store the token in Git CLI. I used to use it all the time:

Code: Select all

git config credential.helper 'store'
The next time you use the token, Git will store it so you won't have to type it again. But this too has similar security implications, if someone gets access to your PC, they theoretically have unlimited push access to your repo, so it may be preferable to store it in a password manager or something. However, this may be too unlikely to matter depending on your situation.
User avatar
a_regular_pear
Posts: 15
Joined: Sat Dec 31, 2022 6:00 pm

Re: How do you authenticate on github

Post by a_regular_pear »

I personally just use ssh keys. It takes a bit of time to setup initially but then it just works.
Post Reply