几款开源git server ssh 协议forced command 参考格式
git over ssh authorized_keys 的force command 处理是比较重要也是核心的
里边包含了权限处理,内部api 调用,git 上传下载处理
gitlab
command="/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell key-<db key id>",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty <ssh public key>
gogs
_TPL_PUBLICK_KEY = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
codefever
command="PATH=$PATH:/usr/local/git/bin && /data/www/codefever-community/ssh-gateway/shell/main $SSH_ORIGINAL_COMMAND 00000000000000000000000000000000",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty <ssh public key>
说明
以上是参考格式,但是有可能会变,对于需要开发自己git ssh 协议的这几个是值得学习的,gitlab 的设计目前是最复杂,但是也是最值得学习的