# How to configure bitrise to access an internally hosted git repository

**URL:** <https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85>\
**Category:** How To\
**Created:** [January 3, 2017, 4:55pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85 "2017-01-03T16:55:11Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 3, 2017, 4:55pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/1 "2017-01-03T16:55:11Z")

</div>

In general you have a couple of options to securely connect to a private repository:

1. Only allow SSH login on the repository server; SSH keys are fully supported on [bitrise.io](https://www.bitrise.io)
2. Restrict by IP: configure your server to only allow connections from certain IP addresses. **We don’t recommend this solution** , as even if you restrict the IP range to [bitrise.io](https://www.bitrise.io) build machine IPs, that means that anyone who runs builds on [bitrise.io](https://www.bitrise.io) will be allowed to communicate with your servers. Additionally, we only have fix IPs for our Mac build machines, the Linux stacks are hosted on Google Compute Engine and we use emphemeral IPs there, so the range is GCE’s ephemeral IP range.
3. Use a VPN: VPNs are in general a good solution to connect to private networks, although in most cases limiting logins on the servers to SSH keys is an easier solution. You can find a guide here: [http://devcenter.bitrise.io/tutorials/vpn-configuration/](http://devcenter.bitrise.io/tutorials/vpn-configuration/)

**If anyone have any other idea / solution, please share it with us, we’d be happy to provide the required features / changes, or to highlight the option here!**

---

<div class="post-metadata">

**Author:** ![ViniciusSossela](https://avatars.discourse-cdn.com/v4/letter/v/f1d935/32.png) [@ViniciusSossela](https://discuss.bitrise.io/u/ViniciusSossela)\
**Post date:** [January 3, 2017, 4:55pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/2 "2017-01-03T16:55:35Z")

</div>

We have a gitlab repository hosted internally, in other words it can only be accessed when connected to our company network, than bitrise can not access our gitlab repo projects. Said that, how to provide just to bitrise the rights to access our gitlab repo? Is that possible? There is some alternative solution for that?

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 2, 2017, 12:13pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/4 "2017-01-02T12:13:27Z")

</div>

Because you mentioned that:

> in other words it can only be accessed when connected to our company network, than bitrise can not access our gitlab repo projects.

You most likely need a VPN, to connect the build environment (virtual machine) to your own private / company network, so that it can access the repository. For this you can follow the guide [Redirecting… - Bitrise Docs](http://devcenter.bitrise.io/tutorials/vpn-configuration/)

A couple of notes / highlights:

- You have to install and configure the VPN **before** the `Git Clone` step if you need the VPN to access the repository.
- You can use a simple `Script` step to install and configure the VPN access
- Setup note: Unfortunately you can’t customize the scanner to activate a VPN session, but you can use a [sample app](https://github.com/bitrise-samples) repository or any other non VPN protected repository during the _Add New App_ process, and then change the repository to the VPN protected one on the app’s **Settings** tab.

Let us know if you have any questions!

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [September 20, 2017, 10:43am UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/5 "2017-09-20T10:43:50Z")

</div>

A macOS only solution, which works with the macOS built in vpn was also reported:

> [@VPN config works locally on bitrise CLI but fails on bitrise.io](http://discuss.bitrise.io/t/vpn-config-works-locally-on-bitrise-cli-but-fails-on-bitrise-io/2504/5):
>
> I just wanted to follow up and say that although I was never able to get my strongswan config working, I was able to get this up and running using the brew package ‘macosvpn’, which allows you to configure VPN connections with the native Mac VPN client through the CLI, and the OSX command scutil. So that might be worth a shot for anyone who finds this and is also struggling with Mac VPN issues. The set-up was easy for me, this is basically the whole script for Mac: brew install macosvpn sudo m…

---

<div class="post-metadata">

**Author:** ![nhammond](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/nhammond/32/103_2.png) [@nhammond](https://discuss.bitrise.io/u/nhammond)\
**Post date:** [October 23, 2017, 9:54am UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/6 "2017-10-23T09:54:30Z")

</div>

i understand that #2 is a generally a bad idea, but how would one go about obtaining the static IPs of the mac build machines? I have the need for part of a PoC for a client and don’t want to go though the hassle of setting up VPNs, etc until the project gets the green light proper

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 23, 2017, 1:07pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/7 "2017-10-23T13:07:26Z")

</div>

@nhammond run a script on the stack you want to get its IP, e.g.

```auto
#!/bin/bash
set -ex

curl ipinfo.io/ip

```

Please note that **we can’t guarantee that the IP will not change**! On the Linux stacks we use ephemeral IPs so that does change for pretty much every build. On macOS the IP will be the same for every build (as it’s the network’s IP, not the specific host/VM’s IP), but it might change any time if we have to change the related hardware for example!

---

<div class="post-metadata">

**Author:** ![nhammond](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/nhammond/32/103_2.png) [@nhammond](https://discuss.bitrise.io/u/nhammond)\
**Post date:** [October 23, 2017, 1:38pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/8 "2017-10-23T13:38:23Z")

</div>

@viktorbenei thanks for that. it’s only iOS for now, and we’ll be looking at other solution going forward but this will get us started.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 23, 2017, 2:38pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/9 "2017-10-23T14:38:13Z")

</div>

@nhammond As a temporary solution this should be fine, just don’t forget that the IP might change in the future 😉

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [November 26, 2018, 6:01pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/10 "2018-11-26T18:01:22Z")

</div>

These a new step in the StepLib, that implements OpenVPN connection as a simple step: [https://www.bitrise.io/integrations/steps/open-vpn](https://www.bitrise.io/integrations/steps/open-vpn)

Can be a nice alternative to script based solution if you use OpenVPN.

---

<div class="post-metadata">

**Author:** ![ae01822](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@ae01822](https://discuss.bitrise.io/u/ae01822)\
**Post date:** [December 21, 2018, 9:38am UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/11 "2018-12-21T09:38:25Z")

</div>

I get this when following step 1

> Failed, error: ssh\_exchange\_identification: Connection closed by remote host
> 
> ```
> fatal: Could not read from remote repository.
> 
> ```

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [January 2, 2019, 10:57am UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/13 "2019-01-02T10:57:44Z")

</div>

Could you please send us a build URL, preferably on our on-site chat or in a different issue thread?

---

<div class="post-metadata">

**Author:** ![alexandreraulin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/alexandreraulin/32/2089_2.png) [@alexandreraulin](https://discuss.bitrise.io/u/alexandreraulin)\
**Post date:** [June 28, 2019, 1:33pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/14 "2019-06-28T13:33:12Z")

</div>

Hi @viktorbenei, @bitce,

Actually my company use Bitrise with Bitbucket, it works fine 👍 . But we move our source code in a Self Hosted Gitlab. So I try to use Bitrise with this Gitlab and I have some troubles :

Context :

- I have a Bitrise Org Standard account.
- Our Gitlab hosting infrastructure filter all the access by IP.

1st (resolved) problem :

- We have whitelisted the Bitrise Mac Runner IP, so the Bitrise runner can pull/push my project. After this test we could use a VPN instead of whitelist this IP.

2nd problem :

- Our Gitlab is not notified by Bitrise to update the state of the builds (for the PR status) :
- I suppose :
  - that Bitrise try to do that using the Gitlab API (that correct ?)
  - but this requests are not made by the Bitrise Mac Runner, so the IP is different from the one I added in the whitelist (that correct ?)

- Somes questions :
  - Is there a way to use the Bitrise Self Hosted Gitlab integration with a IP filtering on Gitlab ? To know the IP of the machine how call the Gitlab API ? To use a VPN on that part of Bitrise ?
  - How do businesses that have a Self Hosted Gitlab usually work to use Bitrise with?

3rd problem :

- On our Gitlab, the HTTPS domain is [gitlab.xxxx.com](http://gitlab.xxxx.com) but the SSH domain is different ([ssh-gitlab.xxxx.com](http://ssh-gitlab.xxxx.com)). When I try to create a new app on Bitrise with the Self Hosted Gitlab integration, the resolved Git address by Bitrise is `git@gitlab.xxxx.com` and not `git@ssh-gitlab.xxxx.com`. And I can’t edit it, so I cant’ setup the app on Bitrise.  
For example on the Tower Mac app, if I try to clone a repo from that Gitlab Self Hosted with my account logged in Tower, the resolved Git address is `git@ssh-gitlab.xxxx.com`

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [July 4, 2019, 12:42pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/15 "2019-07-04T12:42:52Z")

</div>

Hi @alexandreraulin!

Glad to hear you were able to work through most of these obstacles! 🙂

About your status updates, you can simply search for the “GitLab Status” step in our step library and you can use that to communicate between the services!

As for the 3rd problem, we’ve discussed this briefly and the easiest workaround is, while Adding the new app you provide the git address manually instead of selecting the default Bitrise GitLab integration.

---

<div class="post-metadata">

**Author:** ![damien.murphy](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/damien.murphy/32/4535_2.png) [@damien.murphy](https://discuss.bitrise.io/u/damien.murphy)\
**Post date:** [January 14, 2020, 4:37pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/16 "2020-01-14T16:37:18Z")

</div>

Updated IPs for Public cloud no longer require a range when using GCE.

See: [https://devcenter.bitrise.io/infrastructure/virtual-machines/#whitelisting-build-machine-ips](https://devcenter.bitrise.io/infrastructure/virtual-machines/#whitelisting-build-machine-ips)

---

<div class="post-metadata">

**Author:** ![lvthn-devops](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lvthn-devops](https://discuss.bitrise.io/u/lvthn-devops)\
**Post date:** [October 1, 2020, 4:04pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/17 "2020-10-01T16:04:13Z")

</div>

HI there, we have an internally hosted gitlab instance that uses an alternate port other than standard 22. How can I set the config for bitrise to use an alternate port?

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [October 22, 2020, 1:35pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/18 "2020-10-22T13:35:37Z")

</div>

Hi @lvthn-devops! Please see: [Configuring SSH port of self-hosted Gitlab](http://discuss.bitrise.io/t/configuring-ssh-port-of-self-hosted-gitlab/11315)

---

<div class="post-metadata">

**Author:** ![callumd](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@callumd](https://discuss.bitrise.io/u/callumd)\
**Post date:** [December 7, 2021, 10:46am UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/19 "2021-12-07T10:46:29Z")

</div>

hello, I know this is an old thread but since I am not getting any where with my VPN connection setup, I thought I will take my chances here. Up front apologize for that.

Is VPN connectivity well documented some where? I am asking because I am seeing a lot of old posts, dating 3-5 years back showing steps but I don’t know if there are relevant anymore.

I am simply looking for a document which shows how VPN configuration is being achieved as of today & how to include the step, what to write in step.yml or step.sh.

I am reading a lot of old posts & completely out of my depths here.

Any help will be deeply appreciated.

---

<div class="post-metadata">

**Author:** ![cathy.harmon](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/cathy.harmon/32/2674_2.png) [@cathy.harmon](https://discuss.bitrise.io/u/cathy.harmon)\
**Post date:** [December 17, 2021, 5:06pm UTC](https://discuss.bitrise.io/t/how-to-configure-bitrise-to-access-an-internally-hosted-git-repository/85/20 "2021-12-17T17:06:05Z")

</div>

Hello,

Have you reviewed the section “[Connecting to a VPN during a build](https://devcenter.bitrise.io/en/builds/connecting-to-a-vpn-during-a-build.html#ot-fltr-modal)” in the devcenter? This might be a good place to start.

One thing to note, the “Connect to OpenVPN Server” step uses a basic configuration and does not provide for a way to alter this configuration. If your VPN configuration differs, we typically suggest using the script from the step as a sample for you to create a custom step using your VPN configuration. ([GitHub - bitrise-steplib/bitrise-step-open-vpn: Bitrise step to establish a VPN connection with the specified OpenVPN server.](https://github.com/bitrise-steplib/bitrise-step-open-vpn))  
If you have specific questions or run into problems, please open a ticket with support.

Thanks,  
Cathy
