Skip to content

SSH install fails for GitHub Enterprise Data Residency (custom SSH username) #176

@dotned

Description

@dotned

Problem

skillshare install fails when the source is a GitHub Enterprise (GHE) instance using Data Residency, because these instances require a custom SSH username rather than the standard git@.

GHE Data Residency instances use the subdomain as the SSH username. For example, an instance at acme.ghe.com requires SSH connections as acme@acme.ghe.com — the server rejects git@acme.ghe.com entirely.

Reproduction (extrapolated, not tested against the fix)

# This is how the remote looks in .git/config for a GHE DR instance:
# acme@acme.ghe.com:MyOrg/my-skills.git

# Attempting to install via SSH fails:
skillshare install git@acme.ghe.com:MyOrg/my-skills --track
# ✗ failed to clone repository: Could not read from remote repository.

# Using the actual username format isn't recognised:
skillshare install acme@acme.ghe.com:MyOrg/my-skills --track
# ✗ invalid source / fails to parse

Root Cause

In internal/install/source.go:

  1. Line 56 — the SSH regex only matches the literal git@ prefix:

    var gitSSHPattern = regexp.MustCompile(`^git@([^:]+):([^/]+)/(.+?)(?:\.git)?(?://(.+))?$`)
  2. Line 182 — the prefix check only recognises git@:

    strings.HasPrefix(input, "git@") ||
  3. Line 312 — the clone URL is reconstructed with hardcoded git@:

    source.CloneURL = fmt.Sprintf("git@%s:%s/%s.git", host, owner, repo)

Suggested Fix

Generalise the SSH pattern to accept any username, and preserve it in the clone URL:

// Accept any user@host: format (captures username separately)
var gitSSHPattern = regexp.MustCompile(`^([^@]+)@([^:]+):([^/]+)/(.+?)(?:\.git)?(?://(.+))?$`)

And in parseGitSSH, preserve the original username:

source.CloneURL = fmt.Sprintf("%s@%s:%s/%s.git", user, host, owner, repo)

The prefix check (line 182) should match any <something>@<something>: pattern rather than just git@.

Why This Matters

GitHub Enterprise with Data Residency is GitHub's model for regulated industries and data sovereignty. These instances are becoming more common. The SSH username is assigned by the platform (matching the subdomain) and cannot be changed to git@.

Backwards Compatibility

This change is fully backwards-compatible — git@github.com:user/repo still matches the generalised pattern. It simply stops rejecting other valid SSH usernames.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions