Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

SSH Permission Denied (publickey): What to Check First

See how to tell whether SSH is offering the wrong key, using the wrong account, or being rejected by the destination—and what to check next.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Permission denied (publickey) means the SSH server rejected public-key authentication; it does not, by itself, mean your key file is corrupt. First verify the host and login name, then use verbose SSH output to see which key your client found and offered. That evidence tells you whether to check the key path or agent, key registration, local permissions, or server-side access.

What the error means—and what to check first

GitHub Docs explains: “A "Permission denied" error means that the server rejected your connection.” The message identifies an authentication failure, but not its cause. GitLab also documents several possible causes, so generating a new key immediately can miss a username, agent, or authorization problem.

As an Amazon Associate I earn from qualifying purchases.

  1. Confirm the destination and account. Check the hostname and intended login name. For Git operations on GitHub, the SSH username is git, so the destination is [email protected]—not your GitHub profile username. Other servers use their own account names.
  2. Inspect the client’s key selection. Run the appropriate verbose command below and look for identity files and messages indicating that a key was offered.
  3. Check how that key is being supplied. Confirm the intended key is available in the current ssh-agent session, or explicitly select it with -i.
  4. Verify authorization. Match the public key or its fingerprint to the destination account or server authorization.
  5. Check local permissions and remaining access rules. A private key the client cannot read, an unsupported key type, missing repository access, or server policy can still prevent login.

Use verbose output to locate the failure

GitHub

For a GitHub SSH connection, run:

ssh -vT [email protected]

Read the output for identity-file discovery and key offers. If no intended identity is found or offered, investigate the path, filename, and agent. If the client offers a key but authentication fails, verify that the matching public key is registered to the intended GitHub account and that you are connecting to the right host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

GitLab

For GitLab, substitute your GitLab instance’s hostname in this command:

#1 Best Overall
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
ssh -Tvvv [email protected]

Look for the same distinction: no intended key offered points toward client-side selection or agent state; an offered but rejected key points toward registration, account, key support, or server authorization. GitLab’s example hostname is a placeholder for your instance, not a universal GitLab address.

If SSH finds no key or offers the wrong one

Check the agent in the session that fails

For the GitHub troubleshooting example, list keys loaded in the current agent with:

ssh-add -l -E sha256

If the expected key is not listed, the agent may not have it loaded in that terminal or session. GitLab likewise identifies agent state as a possible cause when a connection works in one session but not another.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Select a non-default key explicitly

If your private key is not at the default path or has a non-default filename, test with:

ssh -i ~/.ssh/KEY-FILE git@HOSTNAME

Replace KEY-FILE and HOSTNAME with the actual private-key filename and destination. For GitHub, retain [email protected] as the destination. If this works while the ordinary command fails, the issue is likely which identity SSH selects by default.

If a key is offered but rejected

Match the public key to the intended account or server

The private key on your computer must correspond to a public key authorized at the destination. Compare the public key or fingerprint for the identity shown in verbose output with the key registered to the hosting account. On a self-managed or regular SSH server, check the server-side authorized-key configuration for the intended operating-system account; there may be no hosting-account key page.

Rank #3
Sale
Thetis Nano-A FIDO2 Security Key Hardware Passkey Device with USB Type A, TOTP/HOTP, FIDO2.0 Two Factor Authentication 2FA MFA, Works with Windows/mac/iOS/Android/Linux/Gmail/Facebook/GitHub/Coinbase
  • Ultra-Compact FIDO2 Security Key - Plug-and-stay or carry on a keychain. This USB-A hardware security key offers portable, always-on protection for desktop and mobile use. (Item Size: 0.75 X 0.74 IN x 0.25 IN)
  • USB-A Hardware Key for All Devices - Works with USB-A ports on PC, Mac, Android, and other laptop/notebook device. Enables secure, cross-platform login with FIDO2.0 passkey support.
  • FIDO Certified Security Key - Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
  • Passwordless Login with Passkey - Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
  • Advanced Multi-Factor Authentication - Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.

Confirm the username and the kind of access

An SSH key can authenticate an account without granting access to every repository or action. For GitHub Git operations, use the platform’s git SSH username. On other systems, use the server’s correct login account. If SSH authentication succeeds but a repository operation is denied, check account membership or deploy-key access rather than treating it as the same public-key authentication failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check key support and server policy

If the intended key is offered and registered, the destination may not support its type or may reject it under local policy. GitLab notes that ED25519 keys can be incompatible with some FIPS systems. A regular server may also impose its own SSH configuration or account-authorization rules; ask its administrator to verify those settings when you cannot inspect them yourself.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check local key and directory permissions

GitLab’s documented permission checks specify mode 600 for the private key and 700 for the .ssh directory. On a Unix-like system, check or set them with:

Rank #4
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
  • Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
  • Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
  • Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
  • For the driver download and user guide, please visit TrustKey Solutions Home support page.
chmod 600 ~/.ssh/KEY-FILE
chmod 700 ~/.ssh

Use the actual private-key filename in place of KEY-FILE. These permissions address local access to the key; they do not register it with the remote account or grant repository rights.

Choose the next check from the evidence

Verbose output or symptom Next check
Identity file is absent, or no key is offered Confirm the key path and filename, inspect the agent in this session, and try an explicit -i path.
A key is offered but authentication is rejected Compare its public key or fingerprint with the destination’s authorized key; verify host, account, key support, and server policy.
GitHub Git connection uses a personal username Retry with the GitHub-specific SSH username git.
GitLab works in one session but fails in another Check whether the failing session’s agent has the intended key and verify local permissions.
Key is registered, but a repository action is denied Check account or deploy-key access to that repository; authentication and repository authorization are separate checks.

Keep this error distinct from other SSH failures

Permission denied (publickey) is a public-key authentication rejection. It is not the same as a host-key verification warning, DNS resolution failure, a blocked network connection, or a repository authorization error after authentication. GitHub’s troubleshooting index treats these as separate problems; use the message and the point of failure to choose the relevant branch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not make sudo a routine fix for GitHub pushes. GitHub warns that a key created without elevated privileges may not be the key used by sudo git push; changing privilege context can therefore select a different identity rather than fix authentication.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.