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 GitLab's remote repository mirror function
For this I need an HTTPS or SSH url, and I want to do it with SSH.
Question 1: 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?
Question 2: 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 ifpath-to-git-repos/project.git
is owned by user ssh-user, and if there is no other Git hosting services.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.Check
ps -eaf|grep gitlab
on server A: you will see which account is running GitLab.Creates your SSH keys in the account
~/.ssh
folder.From the comments, the trick was:
~git/.ssh
~git/.ssh/id_rsa.pub
over toserverB
,~ssh-user/.ssh/authorized_keys
to test the ssh connection from the root account (since the git account is limited to GitLab command)
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:
And the mirroring can start working.