Skip to content

SSH credential host matching fails for git@host format #175

@javerberg

Description

@javerberg

Bug Description

When adding an SSH credential with the host format git@bitbucket.org, the credential is not matched when trying to clone a repository. The clone fails with "Permission denied (publickey)".

Steps to Reproduce

  1. Go to Settings > Git Credentials
  2. Add an SSH credential with host git@bitbucket.org (the pre-filled format when selecting SSH type)
  3. Save the credential
  4. Try to clone a repo from that host, e.g., git@bitbucket.org:user/repo.git
  5. Clone fails with authentication error

Expected Behavior

SSH credential should match and authentication should succeed.

Root Cause

  1. Frontend pre-fills git@github.com when selecting SSH type (frontend/src/components/settings/GitCredentialDialog.tsx:180), suggesting this format is valid
  2. Backend's getSSHCredentialsForHost (backend/src/utils/git-auth.ts:130) doesn't normalize the git@ prefix
  3. When cloning, extractHostFromSSHUrl extracts just bitbucket.org from the repo URL
  4. Comparison: git@bitbucket.org ≠ bitbucket.org → no match found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions