假设在带有 Git 存储库的服务器上的 ~/.ssh/authorized_keys 中有大量 ssh 公钥列表,一般格式为“user@mail.com”
我想为 pre-receive 钩子编写 bash 脚本,它检查哪个 SSH 密钥用于推送提交,然后在收到之前对提交执行某些操作。所以剧本的大纲是..
#!/bin/sh
#
<Check key which was used from authorized_keys for the commit>
<Print email corresponding to the SSH key to a file as a log>
<Do some other stuff here>
但是由于服务器存储了公钥,而私钥用于推送提交,是否可以检查使用了哪个密钥?如果有怎么办?
抱歉,如果我遗漏了一些明显的东西,只需要一些指导即可开始。
任何帮助表示赞赏,谢谢。