这是一个概念问题。
在设置到 gitbucket/github 的 ssh 连接时,我正在创建一个私有 ssh 密钥,然后用于创建公共 ssh 密钥。
然后我将公钥添加到 gitbucket。
因此,由于我的计算机持有私钥,它可以解密来自 gitbucket 的加密消息。
所以我理解例如 git clone 是如何工作的。
但是 gitbucket 没有自己的私钥,我没有向我的计算机添加由该(不存在的)私钥生成的公钥。那么 git push 应该如何通过 ssh 工作???
But gitbucket has no own private key
It doesn't need a private key, only the public one in order to authenticate you.
Once gitbucket knows who is contacting for a clone or a push, it will allow the operation.
For the push, it works if you are the owner of the repo to which you are pushing to.
For the authentication part (ssh/PublicKeyAuthenticator.scala
) in gitbucket, see for instance:
src/main/scala/model/SshKey.scala
for retrieving the usernamesrc/main/scala/service/SshKeyService.scala
for storing the username along with the public key.The server side (gitbucket) needs only the public key because of the way public key cryptography works.