publickey Git Origin: Build & delivery OSI layer 7 · Application Last updated 12 Oct 2026

Git: Permission denied (publickey). fatal: Could not read from remote repository.

SSH authentication to GitHub/GitLab/Bitbucket failed — no key, wrong key, or the key isn’t added to your account.

Exact message you may see Permission denied (publickey)Could not read from remote repositoryPlease make sure you have the correct access rights
Seen on: Git Linux

Meaning

The remote uses SSH (git@github.com:…) and the server didn’t accept any key your SSH client offered.

Common causes

  • No SSH key generated
  • Public key not added to the Git host account
  • ssh-agent not running/key not loaded
  • Wrong key used (multiple accounts)
  • Corporate network blocks port 22

⚡ Quick fix

  1. Test: ssh -T git@github.com
  2. Generate a key: ssh-keygen -t ed25519 -C "you@example.com"
  3. Add ~/.ssh/id_ed25519.pub to your Git host account
  4. ssh-add ~/.ssh/id_ed25519
  5. Or switch the remote to HTTPS with a token

Detailed fix by platform

Git

  1. Debug which key is offered:
    bash
    ssh -vT git@github.com
    # Port 22 blocked? Use SSH over 443:
    # ~/.ssh/config
    Host github.com
      Hostname ssh.github.com
      Port 443
      User git

How to diagnose

  1. Remote — SSH or HTTPS URL?
  2. Key — Which key does ssh -v offer?
  3. Account — Is that key added?
  4. Network — Port 22 reachable?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Build & delivery. Errors that are often confused with or caused by this one (click to open):

403 — HTTP 403 Forbidden (HTTP)403AADSTS50126 — AADSTS50126: Error validating credentials due to invalid username or password (Azure)AADSTS50126auth/invalid-credential — Firebase Auth: auth/invalid-credential (auth/wrong-password, auth/user-not-found, auth/invalid-login-credentials) (Authentication)auth/invalid-credenti…Authentication failed — fatal: Authentication failed for 'https://github.com/x/y.git/' (Git)Authentication failedbad auth : Authentication failed — MongoDB: MongoServerError: bad auth : Authentication failed (code 8000 / 18) (MongoDB)bad auth : Authentica…Bad configuration option: usekeychain — ssh: /Users/me/.ssh/config: line 5: Bad configuration option: usekeychain (macOS)Bad configuration opt…Could not load the default credentials — Google Cloud: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started (Google Cloud / Firebase)Could not load the de…DefaultAzureCredential failed — DefaultAzureCredential failed to retrieve a token from the included credentials / ManagedIdentityCredential authentication unavailable (Azure)DefaultAzureCredentia…publickey

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.