Brew FQA

Permission denied (publickey)

==> Updating Homebrew...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
2025-12-15_09-47

苹果公司更新了其技术说明 ,指出自 10.12.2 版本起,macOS 包含了 OpenSSH 7.3p1 版本及其新行为。通过 ssh-add -K 添加到钥匙串的密钥在重启后不会自动重新添加到 ssh-agent。

方案一,手动执行下面👇的命令:

ssh-add ~/.ssh/userKey

方案二,或者,在 ~/.ssh 下创建 config 文件(推荐使用这个方式。),内容如下:

Host * (asterisk for all hosts or add specific host)
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile <key> (e.g. ~/.ssh/userKey)

Ref: