jer*_*rry 10 git ssh public-key-encryption
我想为 git 使用其他 IdentityFile。我想动态使用它,而不是通过配置。我这样做:
$ GIT_SSH_COMMAND='ssh -i /home/my_user/.ssh/id_ed25519' git pull origin master
repository access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
pub 密钥“id_ed25519.pub”在我的 bitbucket 中。
这也失败了:
$ git pull origin master
repository access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
和:
$ git remote -v
origin git@bitbucket.org:company123/repo456.git (fetch)
origin git@bitbucket.org:company123/repo456.git (push)
Run Code Online (Sandbox Code Playgroud)
将 “-v”添加到'ssh -i /home/my_user/.ssh/id_ed25519'表明正在使用我的RSA密钥,而不是ED。为什么?
小智 8
我最近的 Ubuntu 版本也有同样的问题:
使用 -vvv 显示以下内容:
debug2: key: /home/ubuntu/.ssh/id_rsa (0x5628e48246d0), agent
debug2: key: /home/ubuntu/code/id_rsa (0x5628e4820af0), explicit
Run Code Online (Sandbox Code Playgroud)
添加-o IdentitiesOnly=yes解决了它。
完整git命令:
GIT_SSH_COMMAND='ssh -o IdentitiesOnly=yes -i /home/ubuntu/code/id_rsa -F /dev/null' git pull
Run Code Online (Sandbox Code Playgroud)
检查您的命令(是 git 直接调用还是通过别名调用)和配置:
正如我在“使用GIT_SSH_COMMAND”中提到的, git config -l 可能会显示其他会覆盖环境变量的配置。
检查 的返回git config core.sshCommand。
最后,GIT_SSH_COMMAND意味着 Git 2.10+,所以如果你的 Git 版本太旧,你需要先更新它。
| 归档时间: |
|
| 查看次数: |
9886 次 |
| 最近记录: |