Change SSH repo url in GitLab - gitlab

I have gitlab on my server. URL, for example: https://git.site.com
On project page I have similar URL for my repo:
How I can change path only for ssh repo path? I need IP address of my server, not URL

Change this in the /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_ssh_host'] = 'gitssh.example.com'
and then run gitlab-ctl reconfigure

You should take a look at external_url configuration field: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
If you're using Omnibus, you can also custom the SSH host: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L39

Related

How do I force gitlab runner to use the host's domain name instead of ip address?

My company has a bitnami gitlab installation that we self-host. While I manage the gitlab installation, I am not an expert on it by any stretch. A few months back, I configured a project to use a gitlab runner in order to perform unit tests when the project is committed.
Today, when I pushed a commit, the gitlab runner tried to pull from the ip address using ssl. How do I tell it to pull the commit using the domain name?
I want it to use https://gitlab.ourcompany.com but it is using https://10.1.3.3
NOTE: not our real ip address or host name:
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/full-stack/apigw/.git/
fatal: unable to access 'https://10.1.2.3/full-stack/apigw.git/': SSL: no alternative certificate subject name matches target host name '10.1.2.3'
I found the answer after posting the question. Leaving both here for others.
It turns out that our gitlab.rb config file had the external_url set incorrectly. Here are the steps to change that:
/etc/gitlab/gitlab.rb
# other entries omitted for brevity
# was external_url 'https://10.1.2.3'
external_url 'https://gitlab.ourcompany.com'
Then reload your settings:
sudo gitlab-ctl reconfigure

Why some gitlab project clone with SSH do not have SSH schema?

when I watch a tutorial:
when clone a project with SSH, it shows git#xxx like below:
but when I use my Gitlab in practice:
there have schema ssh://, what's the difference?
ssh://git#gitlab.demo.com:222/xxx
That depend on how the custom SSH URL was set for your GitLab instance:
gitlab-ctl show-config | gitlab_ssh_host
The default one uses the default SSH URL scheme, using '/' only.
But you can set it to a SCP-style URL, without ssh://, and using a ':' between domain and URL path.
To change it:
Edit /etc/gitlab/gitlab.rb
Search for gitlab_rails['gitlab_ssh_host'] = 'your.hostname.here'
Update the hostname value and run a gitlab-ctl reconfigure afterwards.

gitlab change hostname to ip/gitlab

I installed Gitlab from source using this manual https://docs.gitlab.com/ce/install/installation.html
Now GitLab work on adress http://gitlab.example. I want to change hostname to 192.168.1.1/gitlab.
I changed in file /home/git/gitlab/config/gitlab.yml
host: gitlab.example to host: 192.168.1.1/gitlab
in file /home/git/gitlab-shell/config.yml
gitlab_url: http://gitlab.example
to gitlab_url: http://192.168.1.1/gitlab
I use Apache2.4 and configure with this example
https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/web-server/apache/gitlab-apache24.conf
I changed ServerName gitlab.example to gitlab or 192.168.1.1/gitlab
But it doesn't work.
What i forget? How can I change URL of gitlab.
Can I use gitlab.example and 192.168.1.1/gitlab at the same time?
Thank for your answers.
The servername cannot contain a /, so 192.168.1.1/gitlab will not work.
You could try simply 192.168.1.1
But if you do not know how to configure apache, you might want to try the ombnibus installation instead...

Change SSH host for cloning

Is there any way to change default ssh host for gitlab (displayed at top of repository view in web interface)? I mean only for SSH in clone urls.
For example I have my gitlab installation on git.example.com, but example.com also points to the same machine (different site). Can I change ssh clone urls from:
git clone git#git.example.com:user/repository
to:
git clone git#example.com:user/repositiory
but for http and https leave it with git.example.com?
Yes,
If you are using the omnibus package you can edit /etc/gitlab/gitlab.rb and add gitlab_rails['gitlab_ssh_host'] = 'example.host.com'
There is the equivalent option somewhere in gitlab.yml : ssh_host: example.host.com
Yes.
If your subdomain behaves the same way your actual domain does, it should not be a problem. If the subdomain points to the same IP, git or ssh for that matter should not bother.

Using gitlab behind router and portforwarding?

My current setup is that I have an Ubuntu VM with gitlab installed (gitlabVM). Gitlab is running on nginx over port 8888
My router is configured as the following:
External 4322 -> gitlabVM:22
External 8888 -> gitlabVM:8888
If I am at a remote location, how do I connect back to do a git clone?
Ive tried git+ssh://myuseringitlab#routerip:4322/root/repo.git but i get an error that there are no repositories.
the url in gitlab is git#localhost:root/repo.git.
Did you try this ?
git+ssh://git#routerip:4322/root/repo.git
You have to provide the git user. Your Gitlab user credentials are asked at the next step (if you don't use SSH auth).

Resources