question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Authentication failed: cloning a private repository — Permission denied (publickey)

See original GitHub issue

Description

Using a new laptop, with a fresh install of GitHub Desktop, authentication fails when I try to clone my own private repository — after passing Checking out files: 100% (1053/1053), done. and attempting Cloning into.

Screenshot of Authentication Failure dialogue

From the logs:

Cloning into '/Users/morgan/Documents/GitHub/repository'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have cycled through the log-out-log-in routine suggested by hequ on #4451, revoking then reinstating GitHub Desktop’s OAuth permissions, but to no avail.

I have tried initiating the clone both within GitHub Desktop, and directly from GitHub using both HTTPS and SSH, but both fail at the same point for similar authentication issues (logs attached below).

I am able to create, and push to, new private repositories on the same account using GitHub Desktop.

The repository is forked from a separate private repository I do not own, if that makes a difference (I guess it shouldn’t).

The help article ‘Error: Permission denied (publickey)’ seems relevant, though it is written for command line users, not GitHub Desktop users.

Do I need to generate a new key pair, and associate them with my GitHub Account? — for HTTPS and SSH?

Version

  • GitHub Desktop: 1.5.1

  • Operating system: macOS 10.14.1

Steps to Reproduce

First Attempt: browser sign in

  1. Sign in to github.com
  2. Install GitHub Desktop
  3. Use ‘Sign in using your browser’ to authenticate GitHub Desktop
  4. Select ‘Clone Repository’ and choose the private repository at issue listed under ‘Your Repositories’, then ‘Clone’
  5. The clone process starts, almost completes, then authentication fails on completion

Second Attempt: manual sign in

As First, except:

  1. Sign in using GitHub Desktop, entering my credentials manually

Third Attempt: HTTPS via browser

As First, except:

  1. Select ‘Clone or Download’ from the repository on github.com —> ‘Clone with HTTPS’ —> ‘Open in Desktop’

Fourth Attempt: SSH via browser

As First, except:

  1. Select ‘Clone or Download’ from the repository on github.com —> ‘Use SSH’ —> ‘Open in Desktop’

Notes

  • Between each attempt, I delete the repository folder from my local GitHub directory
  • After the fourth attempt, I signed out of my account on GitHub Desktop, then revoked its OAuth permissions in the browser; I then signed out of my account in the browser and signed back in again on both, attempting the above steps again

Expected Behavior

I expect step 5. to complete without an authentication failure: I am logged in with the correct username and password, both on GitHub Desktop and the browser, and have full ownership and access privileges for this repository.

Actual Behavior

Using HTTPS: Authentication fails after Checking out files has completed, on Cloning into.

The key line (er, pun) seems to be:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Using SSH: ssh: Authentication fails after Checking out files has completed, on Cloning into.

ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Additional Information

Other possibly related things I did when setting up the new laptop for this purpose:

  • Installed Docker Desktop, built a Docker image, and ran a server locally
  • Installed the AWS CLI
  • Troubleshooting a problem with the local server led me to attempt a fresh clone of the site repository, which is how I ran into this authentication problem

I installed GitHub Desktop on a different new laptop a month ago, and had no issues.

Logs

HTTPS attempt: 2019-01-10.desktop.production.log SSH attempt: 2019-01-09.desktop.production.log

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
shiftkeycommented, Jan 10, 2019

If you’re not able to get to port 22, you might be able to workaround it by rewriting the URLs from config.

These two entries in your ~/.gitconfig global config should do the trick [source]:

# Use https instead of git and git+ssh
[url "https://github.com/"]
  insteadOf = git://github.com/
[url "https://github.com/"]
  insteadOf = git@github.com:
1reaction
shiftkeycommented, Jan 10, 2019

@morqon I think you’re seeing the ongoing SSH failures because your submodules are configured with SSH (these are not affected by whether the initial clone is HTTP or SSH):

Submodule 'source/javascripts/objcjs' (git@github.com:objcio/objcjs.git) registered for path 'source/javascripts/objcjs'
Submodule 'source/stylesheets/objcss' (git@github.com:objcio/objcss.git) registered for path 'source/stylesheets/objcss'
Cloning into '/Users/morgan/Documents/GitHub/morgan-objcio-website/source/articles'...
ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@github.com:objcio/articles.git' into submodule path '/Users/morgan/Documents/GitHub/morgan-objcio-website/source/articles' failed
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Permission denied (publickey) - GitHub Docs
A "Permission denied" error means that the server rejected your connection. There could be several reasons why, and the most common examples are...
Read more >
Quick GitHub 'Permission denied (publickey)' SSH error fix
GitHub 'Permission denied (publickey)' error · You have used an incorrect email address in the GitHub SSH URL · You have not configured...
Read more >
Git: How to solve Permission denied (publickey) error when ...
repo clone · Open terminal and go to user [See attached image] · Open . · git --version [Check for git installation and...
Read more >
git@github.com permission denied (publickey). fatal could not ...
git@github.com: Permission denied (public key).fatal: Could not read from remote repository. - It means GitHub is rejecting your connection ...
Read more >
How to Fix SSH “Permission Denied” with Git Clone - Medium
Solution 1: Use HTTPS. This is the most effortless solution at hand. Simply switch to cloning from the HTTPS path for your Git...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found