Resolve ‘ permission denied (publickey). fatal: could not read from remote repository.’ Error | TECHNO TIMING

The error “ permission denied (publickey)” and “fatal: could not read from remote repository” means Git can’t authenticate with your GitHub account using the SSH key you generated. 

Here’s how to troubleshoot and fix it:

1. SSH Key Configuration

  • Make sure you’ve generated and configured your SSH keys correctly. Check the .ssh folder under your user’s home directory for public and private key files.
  • If the folder is empty, create an SSH keypair using ssh-keygen -o -t rsa -C “[email protected]” and add the public key to your GitHub account settings.

2. SSH Connection

  • Test your SSH connection by running ssh -T If it’s successful, you should see your username and a success message.

3. Public Key Configuration

  • Make sure your public SSH key is added to your GitHub account settings. Go to your account settings, then click on “SSH and GPG keys” in the “Access” section. Compare the list of SSH keys with the output from ssh-add.

4. Network and Firewall Issues

  • Check your network connection and make sure you have internet access. A simple network outage or firewall interference can be the culprit.
  • Review and adjust your computer’s firewall settings or security software to allow Git communications.

5. Repository URL and Permissions

  • Verify the repository URL. Run git remote -v to see the fetch and push URLs. If you see an error, fix it by running git remote set-url origin <repository-URL>.
  • Make sure you have permission to access the repository. If you’re part of a team, check with the repository admin to confirm your account is authorized.

6. Authentication

  • Make sure your SSH keys, credentials or access tokens are set up and up to date. If you’re using a private repository, make sure you have the right access.

7. Verbose Mode

  • Run Git commands in verbose mode by adding the -v option, like git clone -v <repository-URL>. This will give you more detailed error messages to help you find and fix the issue.

Now you should be able to fix the “ permission denied (publickey)” and “fatal: could not read from remote repository” errors and connect to your GitHub repository.


How do I regenerate my SSH key for GitHub?

Generating a new SSH key:

  • Open TerminalTerminalGit Bash.
  • Paste in the text below, replacing the email in the example with your GitHub email. ssh-keygen -t ed25519 -C “”.
  • Enter a secure passphrase. See “Working with SSH key passphrases” for more information.

My network is fine but the error still occurs. What do I do?

Reboot Your Network Device: Just unplug your router’s power cord and wait 10-30 seconds before plugging it back in. If the issue persists, try opening the site on another device connected to the same network.

How do I check and fix the Git repository URL?

Git repository URL: git remote -v. git remote set-url.

Also Read: The Importance of Bank Account and Routing Numbers in Tax Preparation Software

Leave a Comment