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.

  • Django and VirtualEnv Development/Deployment Best Practices
  • How to config git to pull from http and push through ssh in one 'remote'?
  • shell_exec configuration for git pull Godaddy vs Bluehost
  • git merge fails with “Untracked working tree file” on case change
  • “fetch --all” in a git bare repository doesn't synchronize local branches to the remote ones
  • git-svn cannot create a branch to follow SVN branching
  • 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?

  • Visual Studio 2013 does not offer to do merge on Git pull
  • removing files from git
  • Git environment for CodeIgniter project
  • Trying to get the git commit ID in grunt
  • Git merge single file from another repository into my own
  • Move several commits from one branch to another?
  • 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 AAAAB3N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LXBpQ6KWjbjTDTdDkoohFzgbEY=
    

    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.