gitsshgit-pushgitbucket

git push via ssh and who knows the private key?


This is a conceptional question.

When setting up a ssh connection to gitbucket/github, I am creating a private ssh key which is then used for creating the public ssh key.

Then I add the public key to gitbucket.

Hence as my computer hold the private key, it can decrypt the encrypted messages coming from gitbucket.

So I understand for example how git clone works.

But gitbucket has no own private key, and I did not add a public key to my computer which was generated by that (non existing) private key. So how should git push work via ssh???


Solution

  • 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:

    The server side (gitbucket) needs only the public key because of the way public key cryptography works.