我通过 Nix(在Arch Linux上)安装了 Git 。
[gorre@uplink ~]$ uname -a
Linux uplink 4.16.9-1-ARCH #1 SMP PREEMPT Thu May 17 02:10:09 UTC 2018 x86_64 GNU/Linux
[gorre@uplink ~]$ nix-env -q
erlang-20.3.2
git-2.16.3
go-1.10.1
google-drive-ocamlfuse-0.6.25
nix-2.0.2
我将 SSH 配置文件保存在~/.ssh/config
:
[gorre@uplink ~]$ cat ~/.ssh/config
# Bitbucket.org
Host bitbucket.org
#RSAAuthentication yes
IdentityFile ~/.ssh/bitbucket_id_rsa
IdentitiesOnly yes
我 100% 确定私钥/公钥集是正确的。我一直在 SmartGit 中使用它,但是当我尝试通过命令行使用 Git 时,我收到了这个错误:
[gorre@uplink erlang]$ git pull --rebase
sign_and_send_pubkey: signing failed: agent refused operation
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
有没有办法告诉 Git(通过 Nix 安装)引用我的~/.ssh/config
文件?
作为证明,当我“指示”ssh-agent
临时使用我的公钥时会发生这种情况(因此您可以确定我拥有正确的权利):
[gorre@uplink erlang]$ ssh-agent sh -c 'ssh-add ~/.ssh/bitbucket_id_rsa; git pull --rebase'
Enter passphrase for /home/gorre/.ssh/bitbucket_id_rsa:
Identity added: /home/gorre/.ssh/bitbucket_id_rsa (/home/gorre/.ssh/bitbucket_id_rsa)
Already up to date.
Current branch master is up to date.
...在那之后,我可以自由飞行一段时间:
[gorre@uplink erlang_simple_cache]$ git pull --rebase
Already up to date.
Current branch master is up to date.