Is it possible to mirror a private repository on gitlab.com using the SSH protocol?

Gitlab.com has an option to mirror other repository’s on their own site. (Project–> Project setting–> Mirror Repository)

But when I tried to do that using the ssh protocol, the authorization failed because the repository I wanted to clone didn’t recognize the public key of Gitlab.com.

  • Count the number of commits on a Git branch
  • git remote directory path rewrite
  • Expression evaluation mode in haskell for scripting
  • Merge remote changes into a branch that is not the current branch
  • Git error: src refspec master does not match any error: failed to push some refs
  • How do I get the “sha” parameter from GitHub API without downloading the whole file?
  • The page stated:

    If your SSH repository is not publicly accessible, add the public SSH key of the GitLab server to the remote repository.

    The thing is, I could not find an option to add a private key to Gitlab.com or download a public key from Gitlab.com.

    Is this only possible if your own a GitLab server or did I overlook something?

  • git does not recognize exe file
  • How can I create a new remote branch by a commit with no changes?
  • What is right way to organize structure of SPA project with respect of convenient deploy and version control?
  • Some files are being ignored even if they are not in my gitignore, are there any other ignore files other than gitignore?
  • Insert a commit before the root commit in Git?
  • Differences for a certain folder between git branches
  • 3 Solutions collect form web for “Is it possible to mirror a private repository on gitlab.com using the SSH protocol?”

    Gitlab mirroring feature is implemented recently on Nov 2015 but unfortunately it is available only for Gitlab Enterprise Edition:

    Repository Mirroring (EE only) If you want to maintain a mirror of a
    repository in a GitLab instance, you can now let GitLab handle the
    mirroring for you automatically in GitLab Enterprise Edition.

    Check the features comparison between Community and Enterprise Editions
    Either you request EE or use gitlab-mirrors scripts:

    The gitlab-mirrors project is designed to fill in a feature which is currently missing from GitLab: the ability to mirror remote repositories.
    gitlab-mirrors creates read only copies of remote repositories in
    gitlab. It provides a CLI management interface for managing the
    mirrored repositories (e.g. add, delete, update) so that an admin may
    regularly update all mirrors using crontab. It operates by interacting
    with the GitLab API using python-gitlab3. Also, check out this cool
    puppet module for installing and configuring gitlab-mirrors.

    I’m not sure that this will work, but I reckon it’s worth a try. To retrieve the public key of gitlab.com, I ran the following command:

    nmap gitlab.com --script ssh-hostkey --script-args ssh_hostkey=all
    

    The following 3 public keys can then be found in the output:

    ssh-dss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9QlYWrOLXBpQ6KWjbjTDTdDkoohFzgbEY=
    

    Adding these to your repository server might allow it to authenticate the connection properly.

    According to this comment, the key is in /var/opt/gitlab/.ssh/id_rsa and /var/opt/gitlab/.ssh/id_rsa.pub by default. If the keys don’t exist, you can create them manually with sudo -u git -H ssh-keygen and mashing the enter key through the prompts.

    I just tried this on my gitlab-ee 8.7.2 installation and it appears to be working.

    Git Baby is a git and github fan, let's start git clone.