Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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