brew: Brew update fails with Permission denied (publickey).
Please follow the general troubleshooting steps first:
- [DONE] Ran
brew updateand retried your prior step? - [DONE] Ran
brew doctor, fixed as many issues as possible and retried your prior step? brew doctor is clean - [DONE] If you’re seeing permission errors tried running
sudo chown -R $(whoami) $(brew --prefix)?
Bug reports:
Doing brew update, I get the following
➜ brew update Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Fetching /usr/local failed! Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-boneyard failed! Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-versions failed! Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Fetching /usr/local/Library/Taps/dart-lang/homebrew-dart failed! Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-dupes failed! Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Fetching /usr/local/Library/Taps/homebrew/homebrew-x11 failed! Already up-to-date. ➜
Followed multiple hints on the web. This looks like an ssh related error but the reps in question point to https. Please advise. Did not do a brew update for a while and did the 10.11.4 upgrade in between. Still, I have been using some git. Maybe I have screwed something up. Please advise.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (6 by maintainers)
@BM5k figured it out for 10.12, which uses ssh-agent now (cool). Just
ssh-add ~/.ssh/<your rsa file>And then you can
brew updateFWIW I’ve had
In my
~/.gitconfigfor ages and never had a problem until installing the 10.12 public beta.There is some issue with your SSH setup. And you seem to be rewriting
https://github.com/remotes togit@github.com:as can be seen from the last output. Please check your~/.gitconfigfor a line similar toinsteadOf = https://github.com/that you must have added at some point in time (or some tool did for you) to your configuration. Please comment that out by prefixing the line with#and try again.To maybe clarify a bit: I think if you look at your
~/.gitconfigyou’ll find a section that looks like this:This has the effect of transparently rewriting all your GitHub HTTPS URLs to SSH. And this would explain why you see this behavior. This change to
~/.gitconfigwas either made by you or by some Git-related tool you have installed since you’ve last successfully ranbrew update. Do you remember doing something like this in the past 7 weeks (that’s when your last updated Homebrew)?This error can also occur the first time you interact with github when your ‘~/.ssh/known_hosts’ file doesn’t contain an entry for github.
A workaround is to do
git pullorgit clonein some other repo. You’ll be asked to add the github ip to your known hosts. Say yes.brewshould work afterward.Just to make sure, can you post the output of
brew tap-info --installed, to see if these are allhttpsorsshremotes?If those tap remotes are
git@github.com:links, then this may just happen: when you use ssh connections, and it wants to use your private key,gitwill pop up a dialog prompting for a passphrase the first time you use it. Whengitis run from insidebrew, though, those dialogs don’t happen and ssh key usage just fails (maybe because we’re runninggitheadless instead of attached to a tty). This happens to me sometimes, and you see error messages just like this.If this is the case, you can work around it by manually switching in to one of the taps, or any other local GitHub clone using the same ssh identity, and do a
git update. That’ll produce the password prompt and store it for subsequent usage in your session, andbrew updatewill be able to use it.Or switch all the taps back to
httpsremotes.