3 ms·
Personal Access Tokens provide both simpler and better security controls than SSH, so you end up using them in enterprises. You can't create an SSH key with se
by 0xbadcafebee 6y ago
Personal Access Tokens provide both simpler and better security controls than SSH, so you end up using them in enterprises.
You can't create an SSH key with select role permissions like you can with a Personal Access Token. But you do need a PAT to use the API. So you can either have one PAT + one SSH key, or just use one PAT and no SSH key. (Or multiple PATs, for fine-grained access control)
If you use multiple SSH keys in GitHub (which you should be, to access different things) then you have to manually juggle which SSH key you're passing when you pull each repo, because GitHub will just take the first SSH key you have in your ssh-agent that has an account in GitHub. You won't know from looking at a Git URI ("ssh://git@github.com") which one is needed. OTOH, with PAT, you can either make a URL like ("https://user@github.com https://user@github.com") to pre-specify which user to use, or use "https://github.com https://github.com" and specify user and PAT at auth time.
Authentication using SSH requires first accepting the host keys of Github.com, which can rotate, so you have to decide if you're going to bake the host keys into a container, or require a user to accept them (and know when they change if it's a real GitHub key change or a hacker). Or ignore host keys and lose all the security of SSH encryption. The alternative, HTTPS + PAT, requires no such operations, carries less risk, and is less work to implement.
And of course some networks block port 22.
- tialaramex 6y agoYou can configure SSH and Git to use separate keys if that's what you want (although for many people I'd recommend separating far more e.g. if you have work credentials and personal credentials, don't just segment GitHub, run everything on separate physical hardware, or at least a VM) A mistake lots of people make in this case though is they don't set IdentitiesOnly (in OpenSSH). IdentitiesOnly tells SSH that even if it knows how to authenticate as, say, 'me', if you've told it to authenticate as 'employee' in a particular configuration it should insist on only authenticating as 'employee' never 'me'. If you don't do that you can get confusing behaviour (and of course a privacy hole) on GitHub if your SSH agent knows your 'me' credentials and you try to use an account set to 'employee' credentials, as it uses the wrong ones.
- Macha 6y agoAlso if you have a lot of keys set up and don't tell it to use a specific key, you can get login failures as the first 5 it tries aren't correct
- u801e 6y ago> You can't create an SSH key with select role permissions like you can with a Personal Access Token. The ssh-keygen manpage has a section under the heading CERTIFICATES that describes the permissions that are configurable when generating the certificate (though those permissions are ssh specific as opposed to the permissions for API access).