Skip to content

Map ssh_host to API host when resolving git remotes#61

Merged
andrew merged 1 commit intomainfrom
ssh-host
Apr 13, 2026
Merged

Map ssh_host to API host when resolving git remotes#61
andrew merged 1 commit intomainfrom
ssh-host

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Apr 13, 2026

Closes #41.

Self-hosted GitLab can serve git-over-ssh on a different host than the web UI and API. A remote like git@ssh.gitlab.test:owner/repo.git parses to domain ssh.gitlab.test, which then fails forge detection or hits the wrong API endpoint.

This adds an ssh_host key to the per-domain config:

[gitlab.test]
type = gitlab
ssh_host = ssh.gitlab.test

When repoFromGitRemote parses a remote URL, it checks whether the extracted domain matches any configured ssh_host and swaps in the section name (the API host) before building the client. The reverse lookup lives on *Config as DomainForSSHHost.

Without the config the behaviour is unchanged — domains pass through. The mapping only kicks in when explicitly declared.

This is the same approach glab takes (https://gitlab.com/gitlab-org/cli/-/merge_requests/2924).

@andrew andrew merged commit b508419 into main Apr 13, 2026
4 checks passed
@andrew andrew deleted the ssh-host branch April 13, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssh-host and api-host can differ on GitLab self hosted instances

1 participant