Homebrew likely needs a Github API auth token to work correctly, at least with 2FA enabled Github accounts. The Internet - e.g. https://gist.github.com/willgarcia/7347306870779bfa664e - suggests to add the token to your environment via .bashrc, which is generally a bad idea and gives every started program access to your github account.
- Generate access token via https://github.com/settings/tokens
- Wrap your Access token in a shell script, e.g. ~/bin/brew, or whatever is in your path before the actual brew path:
#!/bin/bash
HOMEBREW_GITHUB_API_TOKEN=xxxx /usr/local/bin/brew "$@"
Rewrite HTTPS to SSH when accessing github via git:
git config --global --add url."[email protected]:".insteadOf "https://github.com/"
see also: https://jacopretorius.net/2018/05/git-error-could-not-read-username.html