[英]The argument “-i” passed to GIT_SSH_COMMAND is being ignored
我想为 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.
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.
并且:
$ git remote -v
origin git@bitbucket.org:company123/repo456.git (fetch)
origin git@bitbucket.org:company123/repo456.git (push)
将“-v”添加到'ssh -i /home/my_user/.ssh/id_ed25519'表明正在使用我的RSA密钥,而不是ED。 为什么?
我最近的 Ubuntu 版本也有同样的问题:
使用 -vvv 显示以下内容:
debug2: key: /home/ubuntu/.ssh/id_rsa (0x5628e48246d0), agent
debug2: key: /home/ubuntu/code/id_rsa (0x5628e4820af0), explicit
添加-o IdentitiesOnly=yes
解决了它。
完整的git
命令:
GIT_SSH_COMMAND='ssh -o IdentitiesOnly=yes -i /home/ubuntu/code/id_rsa -F /dev/null' git pull
检查您的命令(是直接调用 git 还是通过别名调用)和配置:
正如我在“使用GIT_SSH_COMMAND
”中提到的, git config -l 可能会显示其他会覆盖环境变量的配置。
检查git config core.sshCommand
的返回。
最后, GIT_SSH_COMMAND
表示 Git 2.10+,所以如果你的 Git 版本太旧,你需要先更新它。
如果有人在GIT_SSH_COMMAND
上设置GIT_SSH_COMMAND
时遇到此问题,然后在另一行上实际运行git
命令,请尝试以下操作之一:
GIT_SSH_COMMAND
:$ GIT_SSH_COMMAND="ssh -i ${key_location}" git clone [...]
或者……
GIT_SSH_COMMAND
$ export GIT_SSH_COMMAND="ssh -i ${key_location}"
$ git clone [...]
我在找到要使用的密钥后立即设置GIT_SSH_COMMAND
,然后在几行之后运行git
。 我错误地删除了export
并破坏了git
命令。
由于这是搜索“GIT_SSH_COMMAND”时最热门的 google 链接之一,并且该问题比答案更受欢迎,因此可能是某些访问者遇到了与 OP 相同的问题,但原因与其他答案推荐的原因不同。 希望这对某人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.