Coding⏱️ 2 min read📅 2026-05-31

How to Fix: GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly

GitHub permission denied error due to public key issues.

Quick Answer: Check if your public key is correctly added to GitHub. Try running `ssh -T git@github.com` to verify the connection and add the key manually.

The 'Permission denied (publickey). fatal: The remote end hung up unexpectedly' error typically occurs when the Git repository on GitHub is unable to verify your public key. This can be due to various reasons, such as an incorrect or missing public key, a mismatch between your local and remote public keys, or an issue with your network connection.

🛠️ Step-by-Step Verified Fixes

Method 1: Verify Public Key

  1. Step 1: Run the command `ssh -T git@github.com` to test your connection and verify that you can authenticate successfully.

Method 2: Update Public Key

  1. Step 1: Open your terminal and run the command `ssh-add` to add your public key to the SSH agent.

Method 3: Reconfigure GitHub

  1. Step 1: Go to your GitHub settings, click on 'SSH and GPG keys', and then click on the 'New SSH key' button.

🎯 Final Words

To resolve this issue, try one of the above methods and ensure that your public key is correctly configured and verified. If you continue to experience issues, consider reaching out to GitHub support for further assistance.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions