2018-12-05 23:21:45 +05:30
|
|
|
---
|
|
|
|
description: "Set and configure Git protocol v2"
|
|
|
|
---
|
|
|
|
|
|
|
|
# Configuring Git Protocol v2
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/46555) in GitLab 11.4.
|
2019-07-07 11:18:12 +05:30
|
|
|
> Temporarily disabled (see [confidential issue](../user/project/issues/confidential_issues.md)
|
2019-12-04 20:38:33 +05:30
|
|
|
> `https://gitlab.com/gitlab-org/gitlab-foss/issues/55769`) in GitLab 11.5.8, 11.6.6, 11.7.1, and 11.8+.
|
2019-02-02 18:00:53 +05:30
|
|
|
|
|
|
|
NOTE: **Note:**
|
2019-07-07 11:18:12 +05:30
|
|
|
Git protocol v2 support has been temporarily disabled
|
|
|
|
because a feature used to hide certain internal references does not function when it
|
2019-02-02 18:00:53 +05:30
|
|
|
is enabled, and this has a security impact. Once this problem has been resolved,
|
2019-07-07 11:18:12 +05:30
|
|
|
protocol v2 support will be re-enabled. For more information, see the
|
|
|
|
[confidential issue](../user/project/issues/confidential_issues.md)
|
2019-12-04 20:38:33 +05:30
|
|
|
`https://gitlab.com/gitlab-org/gitlab-foss/issues/55769`.
|
2019-01-03 12:48:30 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
Git protocol v2 improves the v1 wire protocol in several ways and is
|
|
|
|
enabled by default in GitLab for HTTP requests. In order to enable SSH,
|
|
|
|
further configuration is needed by the administrator.
|
|
|
|
|
|
|
|
More details about the new features and improvements are available in
|
|
|
|
the [Google Open Source Blog](https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html)
|
|
|
|
and the [protocol documentation](https://github.com/git/git/blob/master/Documentation/technical/protocol-v2.txt).
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
From the client side, `git` `v2.18.0` or newer must be installed.
|
|
|
|
|
|
|
|
From the server side, if we want to configure SSH we need to set the `sshd`
|
2019-02-15 15:39:39 +05:30
|
|
|
server to accept the `GIT_PROTOCOL` environment.
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
In installations using [GitLab Helm Charts](https://docs.gitlab.com/charts/)
|
2019-02-15 15:39:39 +05:30
|
|
|
and [All-in-one docker image](https://docs.gitlab.com/omnibus/docker/), the SSH
|
|
|
|
service is already configured to accept the `GIT_PROTOCOL` environment and users
|
|
|
|
need not do anything more.
|
|
|
|
|
|
|
|
For Omnibus GitLab and installations from source, you have to manually update
|
2020-03-09 13:42:32 +05:30
|
|
|
the SSH configuration of your server by adding the line below to the `/etc/ssh/sshd_config` file:
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```plaintext
|
2018-12-05 23:21:45 +05:30
|
|
|
AcceptEnv GIT_PROTOCOL
|
|
|
|
```
|
|
|
|
|
|
|
|
Once configured, restart the SSH daemon. In Ubuntu, run:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```shell
|
2018-12-05 23:21:45 +05:30
|
|
|
sudo service ssh restart
|
|
|
|
```
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
|
|
|
In order to use the new protocol, clients need to either pass the configuration
|
2019-12-04 20:38:33 +05:30
|
|
|
`-c protocol.version=2` to the Git command, or set it globally:
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```shell
|
2018-12-05 23:21:45 +05:30
|
|
|
git config --global protocol.version 2
|
|
|
|
```
|
|
|
|
|
|
|
|
### HTTP connections
|
|
|
|
|
|
|
|
Verify Git v2 is used by the client:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```shell
|
2018-12-05 23:21:45 +05:30
|
|
|
GIT_TRACE_CURL=1 git -c protocol.version=2 ls-remote https://your-gitlab-instance.com/group/repo.git 2>&1 | grep Git-Protocol
|
|
|
|
```
|
|
|
|
|
|
|
|
You should see that the `Git-Protocol` header is sent:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```plaintext
|
2018-12-05 23:21:45 +05:30
|
|
|
16:29:44.577888 http.c:657 => Send header: Git-Protocol: version=2
|
|
|
|
```
|
|
|
|
|
|
|
|
Verify Git v2 is used by the server:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```shell
|
2018-12-05 23:21:45 +05:30
|
|
|
GIT_TRACE_PACKET=1 git -c protocol.version=2 ls-remote https://your-gitlab-instance.com/group/repo.git 2>&1 | head
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response using Git protocol v2:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```shell
|
2018-12-05 23:21:45 +05:30
|
|
|
$ GIT_TRACE_PACKET=1 git -c protocol.version=2 ls-remote https://your-gitlab-instance.com/group/repo.git 2>&1 | head
|
|
|
|
10:42:50.574485 pkt-line.c:80 packet: git< # service=git-upload-pack
|
|
|
|
10:42:50.574653 pkt-line.c:80 packet: git< 0000
|
|
|
|
10:42:50.574673 pkt-line.c:80 packet: git< version 2
|
|
|
|
10:42:50.574679 pkt-line.c:80 packet: git< agent=git/2.18.1
|
|
|
|
10:42:50.574684 pkt-line.c:80 packet: git< ls-refs
|
|
|
|
10:42:50.574688 pkt-line.c:80 packet: git< fetch=shallow
|
|
|
|
10:42:50.574693 pkt-line.c:80 packet: git< server-option
|
|
|
|
10:42:50.574697 pkt-line.c:80 packet: git< 0000
|
|
|
|
10:42:50.574817 pkt-line.c:80 packet: git< version 2
|
|
|
|
10:42:50.575308 pkt-line.c:80 packet: git< agent=git/2.18.1
|
|
|
|
```
|
|
|
|
|
|
|
|
### SSH Connections
|
|
|
|
|
|
|
|
Verify Git v2 is used by the client:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```shell
|
2018-12-05 23:21:45 +05:30
|
|
|
GIT_SSH_COMMAND="ssh -v" git -c protocol.version=2 ls-remote ssh://your-gitlab-instance.com:group/repo.git 2>&1 |grep GIT_PROTOCOL
|
|
|
|
```
|
|
|
|
|
|
|
|
You should see that the `GIT_PROTOCOL` environment variable is sent:
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
```plaintext
|
2018-12-05 23:21:45 +05:30
|
|
|
debug1: Sending env GIT_PROTOCOL = version=2
|
|
|
|
```
|
|
|
|
|
|
|
|
For the server side, you can use the [same examples from HTTP](#http-connections), changing the
|
|
|
|
URL to use SSH.
|