Git does not have its own authentication built in. Git simply uses whatever the operating system provides.
At the operating system level, using a Linux server, you would only be able to ssh <server>
as yourself if you yourself have an account on that Linux server. I suspect you do not have an account on GitHub's servers. :-) But some guy named git
does.
His log-in shell, though, is not a regular command shell. It will not run general Linux commands. When git (is that John Git, or is it Git Smith?) logs in, "his" "shell" is redirected (actually through ssh itself) to a separate program, not part of Git, that compares the incoming keys against—yes, you got it—all keys for all users. That lets his shell figure out that, no, it's not John Git, it's jwa
. It's that shell, or another part spawned from it, that gives jwa
access to jwa
's repositories.
The gitolite
code (mostly written in Perl) provides an example of how to do this on any Unix-like server. Once you get past a few hundred authorized keys, though, it's probably wise to stop using linear searches to look up keys, i.e., to stop using the stuff built in to sshd itself. Looking up the key in a database will be a lot faster.