Hii Gitlab Forum,
I want to set push mirror from my gitlab self hosted that is hosted on docker on an ubuntu server to gitlab.com using ssh public key auth method.
I don’t want to set it up using token - as it is not very secure. And my organization wants to use the ssh public key method.
Now, when I set it manually, I give the url
Example - ssh://git@gitlab.com/devops-latest/mirror-test.git (url of target repo)
- then I click on detect host keys and verify signatures
- then authentication method is public ssh key
- username is git
and then mirror is set. Once the mirror is set, I get an option to copy the public key, and then I set that public key as a deploy key in the target repo. And then mirroring works.
But, when I do the same using api - using this curl request
curl --request POST \
--data "enabled=yes&url=ssh://git@gitlab.com/devops-latest/mirror-test.git&auth_method=ssh_public_key" \
--header "PRIVATE-TOKEN: ****" \
"https://gitlab.example.com/api/v4/projects/745/remote_mirrors"
Using this cur request the mirroring is set - but I cant see the option to copy the public key.
Also, I thought that maybe the public key is returned in the response which it does not.
This is the reponse
So, please tell me how can I get the public key. How can I set push mirror using api properly.
Is there a way I can use my own public key. I have seen few docs that tell to use known_host – does that work? and how can I use that?
Also, is there a way I can use one public key to set mirror in multiple repo?
This is the info::
Source gitlab - Gitlab self hosted version - v16.9.1-ee – hosted on docker on ubuntu 22.04 server
Target gitlab - gitlab.com – 17.0.0-pre
Mirror - Push
Method – SSH Key
Thankyou in advance. Awaiting your response as soon as possible.
Priyanshi Sarad
DevOps Enginner at Webelight Solutions