2013-03-02 77 views

回答

2

GitHub正在利用OpenSSH的功能。请参见sshd(8)手册页中的“AUTHORIZED_KEYS FILE FORMAT”部分。它说,在authorized_keys文件中的每一行由以下部分组成:

<options> <keytype> <base64-encoded key> <comment> 

其中一个支持的选项是command

  • command="command"指定每当这个关键是command执行用于认证。用户提供的命令(如果有)将被忽略。

因此,GitHub上可以做他们的~git/.ssh/authorized_keys文件这样的东西:

command="foo -u user1" <user1's key stuff here> 
command="foo -u user2" <user2's key stuff here> 

现在,每当user1日志中,服务器运行foo -u user1。因此,foo脚本知道user1已登录,而不是某个其他用户。