Mirror gitlab to github over ssh

Edit: please refer to the docs instead: https://docs.gitlab.com/ee/user/project/repository/mirror/push.html#set-up-a-push-mirror-from-gitlab-to-github


Now that github doesn’t allow password based authentication anymore, it is necessary to use ssh key based authentication methods when setting up a repository mirror.

You should do the following:

Get the ssh URL

A screenshot of github, with the code menu expanded, showing where to copy the ssh URL

First, you should copy the SSH URL. It will look somewhat like this: [email protected]:meesvandongen/ddragon-webp.git

The URL gitlab is expecting however takes a somewhat different form: ssh://[email protected]/meesvandongen/ddragon-webp.git

So, modify the URL to take this form.

Add the URL to gitlab

Go to the repository you want to mirror on gitlab, and choose settings > repository > Mirroring repositories.

The mirroring repositories settings on gitlab

Here,

  • paste the URL from step 1 in the Git repository URL
  • select the appropriate direction
  • select SSH public key as authentication method
  • click Mirror repository

Get the SSH key

The mirrored repositories on gitlab, showing a button to copy SSH public key

Below the setting for adding new repository mirrors is a list of currently mirrored repositories. For the ssh-based repositories, a button is shown, which must be used to copy the SSH key that gitlab will use for authentication on the remote repository.

Authorize the SSH key

Now all that remains is allowing the SSH key on github. On github, under Settings > Deploy keys > Add new, you can paste the key copied in the previous step. Be sure to check allow write access if the direction is push.

The add new deploy key page on github

After this, everything should work as expected.

React: Functional ComponentsClient Side Redirects