我在徘徊 gitHub 如何仅通过使用 sshKey 来限制 repo 访问。
每个人都在使用“git”用户进行连接……但访问权限仅限于您的存储库。
那怎么可能呢?
提前致谢。
最佳答案
GitHub 正在利用 OpenSSH 的一项功能。请参阅 sshd(8) 手册页中的“AUTHORIZED_KEYS FILE FORMAT”部分。它说 authorized_keys
文件中的每一行都包含以下内容:
<options> <keytype> <base64-encoded key> <comment>
支持的选项之一是
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
已登录,而不是其他用户。关于ssh - gitHub 如何限制仅使用 ssh Key 的访问?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15175049/