I have 2 web servers. On server A I have a
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://email@example.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.Answer1:
ssh://firstname.lastname@example.org: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.</blockquote>
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 />
ps -eaf|grep gitlab on server A: you will see which account is running GitLab.<br />
Creates your SSH keys in the account
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
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
to use the SSH URL:
And the mirroring can start working.