5

GitLab has a mirror feature:

https://docs.gitlab.com/ee/user/project/repository/mirror/

and GitHub does not support simple password authentication. I tried to follow

https://meesvandongen.nl/posts/mirror-gitlab-github

Using the target url

ssh://git@github.com:stefaneidelloth/mirror_demo.git

and SSH public key as authentication method.

However, I get an error

Remote mirrors url is blocked: URI is invalid 

from GitLab.

If I specify the target url

https://github.com/stefaneidelloth/mirror_demo.git

I am not able to select SSH public key as authentication method.

=> What are the right settings to mirror a GitLab project to a GitHub project (without PREMIUM edition of GitLab)?

Edit

The second : needs to be replaced with a /.

Suggested by GitHub:

enter image description here

Adding ssh:// prefix is not enough.

Wrong: ssh://git@github.com:stefaneidelloth/mirror_demo.git

Still need to replace : after github.com:

Right: ssh://git@github.com/stefaneidelloth/mirror_demo.git

Then GitLab generates the SSH key for the connection and one needs to copy it to the GitHub project settings (not the user settings), see https://meesvandongen.nl/posts/mirror-gitlab-github

Now I get the next error:

13:get remote references: create git ls-remote: exit status 128, stderr: "ssh connect to host github.com port 22: Connection timed out\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n".

a) Do I need to specify a different port than 22? How? I tried

ssh://git@github.com:443/stefaneidelloth/mirror_demo.git

but that did not help.

b) Do I need to use "Input host keys manually"? What should be specified? I tried to use

SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s

from

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints

but that did not help.

c) I also tried to generate a GitHub AccessToken in the user settings and apply it for the password option of the GitLab Mirror settings. I tried both, https:// and git:// urls. No success.

Stefan
  • 10,010
  • 7
  • 61
  • 117
  • I tried this too. Couldn't get it to work. I got past the error you're getting once I added the generated SSH key to the GitHub repo as a Deploy token with write access. However, while there are no more errors being shown, the GitHub repo does not get updated and hitting refresh just seems to fail without errors. – geoidesic Aug 16 '23 at 14:24

2 Answers2

3

I got this to work after all.

  1. Yes, you need to manually edit the git SSH URL, as you have shown: ssh://git@github.com/stefaneidelloth/mirror_demo.git
  2. Select SSH public key as authentication method.
  3. Then click mirror repository button
  4. Copy the SSH key generated as shown here: https://meesvandongen.nl/posts/mirror-gitlab-github
  5. The key then needs to be added as a Deploy Key to the GitHub Repo, which is done from Settings > Deploy Keys (see figure below)
  6. Click refresh on the mirror. Note that when I first did this, nothing happened, no errors, but also no update. I did it four times and still nothing happened. Then about 27 minutes later, the update happened.

Deploy Keys

geoidesic
  • 4,649
  • 3
  • 39
  • 59
0

"ssh connect to host github.com port 22: Connection timed out" suggests that something is blocking port 22 for github.com - perhaps a proxy or firewall. GitHub has a separate hostname (not github.com) for handling SSH traffic over a rarely-blocked port; your URL for that would need to be ssh://git@ssh.github.com:443/stefaneidelloth/mirror_demo.git.

Jim Redmond
  • 4,139
  • 1
  • 14
  • 18