I am curious as to how programs such as gitolite work -- specifically how do they interact with the SSH protocol to provide a tailored experience. Can somebody provide an example of how I might accomplish something like the following and where I might learn more about this topic?
→ ssh git@github.com
PTY allocation request failed on channel 0
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
A side question: my primary language is JavaScript. Is it possible to accomplish what I want with NodeJS?
gitolite in itself is an authorization layer which doesn't need ssh.
It only needs to know who is calling it, in order to authorize or not that person to do git commands.
SSH is used for authentication (but you can use an Http Apache for authentication as well, for instance)
The way gitolite is called by ssh is explained in "Gitolite and ssh", and uses the ssh mechanism forced command:
The
~/.ssh/authorized_keys
(on the gitolite ssh server) looks like:(forced command = no interactive shell session: it will only provide a restricted shell, executing only one script, always the same)
The fact that the
authorized_keys
calls a perl script (gitolite-shell
) is because Gitolite is written in perl.It could very well call a javascript program.
If your ssh on GitHub without any command, you get a greeting message, like your mention in your question.
Gitolite displays a similar message, as detailed in the
print_version()
function of theinfo
command script:The message looks like:
The late 2013 Gitolite documentation now includes that diagram which summarizes all the pieces:
The basic steps are:
In other words, for these things to work, you have to get public keys from the users and then generate a list (file, database, whatever) that pairs a key to a user and permissions.
Note that sshd does a linear scan of the ~/.ssh/authorized_keys file. Once you get about 3000 keys in there, people whose keys appear later in the file start to notice the lag -- it begins to be more than network lag :-)
That is one reason why github has their own patched version of sshd. They have far too many users to be able to manage with normal sshd!