Connecting to Git repo on own web server with SSH


I have 2 web servers. On server A I have a GitLab installed.

On server B I just initialized a bare Git repo.

Now I want to automatically push the GitLab repo to server B using <a href="https://gitlab.com/help/workflow/repository_mirroring#pushing-to-a-remote-repository" rel="nofollow">GitLab's remote repository mirror function</a>

For this I need an HTTPS or SSH url, and I want to do it with SSH.

<strong>Question 1:</strong> What is the url I need to insert there? I guess it should be something like ssh://ssh-user@server-b.com:path-to-git-repos/project.git. Is that right?

<strong>Question 2:</strong> Since the user connecting to the url is GitLab's Git user, I guess I need to create an own SSH key for this user and add the public key to my web server. How can I do this since the Git user has no permissions to do anything except from Git commands on terminal level? I guess I need to create it with the root user of my GitLab server, but how do I do that? I can't even find the Git user's home dir when I'm connected as root.


ssh://ssh-user@server-b.com:path-to-git-repos/project.git is the correct URL if path-to-git-repos/project.git is owned by user ssh-user, and if there is no other Git hosting services.


Since the user connecting to the url is GitLab's Git user, I guess I need to create an own SSH key for this user and add the public key to my web server.


Yes, a dedicated private/public ssh key pair needs to be created, with the public one going to serverB ~ssh-user/.ssh/authorized_keys: you can copy it yourself.<br /> Check ps -eaf|grep gitlab on server A: you will see which account is running GitLab.<br /> Creates your SSH keys in the account ~/.ssh folder.

From the comments, the trick was:

<ul><li>to generate ssh key pairs from the root account, and move the keys to ~git/.ssh</li> <li>to copy ~git/.ssh/id_rsa.pub over to serverB, ~ssh-user/.ssh/authorized_keys</li> <li>

to test the ssh connection from the root account (since the git account is limited to GitLab command)

ssh -i ~git/.ssh/id_rsa ssh-user@serverB </li> </ul>

That has the side effect to fill out the ~root/.ssh/known_hosts file, that can then be copied over to ~git/.ssh/known_hosts


to use the SSH URL:

ssh://ssh-user@server-b.com/absolute/path-to-git-repos/project.git </li> </ul>

And the mirroring can start working.


  • detecting connection lost in spark streaming
  • New-PSSession in an Azure-runbook (ARM)
  • How to upload files in php using html
  • qt how to know that a pushbutton is clicked?
  • Does SmartGit support git-svn?
  • Granting permissions to Azure Active Directory Web Application automatically
  • Does Apportable support to build library binary (.a/.so)?
  • How to handle elastic beanstalk deployment so it uploads only changed files
  • How to install node-mysql?
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Does Mobilefirst provide a provision to access web services directly?
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • Switching to Release Build causes runtime error in Web Reference
  • Why value captured by reference in lambda is broken? [duplicate]
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Google cloud sdk not working when python points python3
  • QuartzCore.framework for Mono Develop
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Cannot Parse HTML Data Using Android / JSOUP
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • Why joiner is not used after Sequence generator or Update statergy
  • how does django model after text[] in postgresql [duplicate]
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Authorize attributes not working in MVC 4
  • unknown Exception android
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • Recursive/Hierarchical Query Using Postgres
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How can I use threading to 'tick' a timer to be accessed by other threads?