我想使用配置来设置 sshCommand 而不是环境变量。但不起作用
这是发生的事情
➜ GIT_SSH_COMMAND='ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null' git ls-remote
From git@github.com:syn2cat/Level2.lu.git
fcaa5a2e63499568dd916e7b18f950b311781bd0 HEAD
fcaa5a2e63499568dd916e7b18f950b311781bd0 refs/heads/master
a542061a64d3698d5da54d63456b26932fe549a2 refs/pull/1/head
➜ git config core.sshcommand
ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null
➜ git ls-remote
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
和调试,它不使用来自 core.sshCommand 的值
➜ GIT_TRACE=1 git ls-remote
13:46:15.366401 git.c:344 trace: built-in: git 'ls-remote'
13:46:15.366564 run-command.c:334 trace: run_command: 'ssh' 'git@github.com' 'git-upload-pack '\''syn2cat/Level2.lu.git'\'''
版本
➜ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
➜ git --version
git version 2.7.4
最佳答案
core.sshCommand 选项已添加到 git 2.10.0 .您正在运行 2.7.4,它没有该功能。如果你想使用它,你需要升级到一个新的 Git。
关于git 忽略配置 core.sshcommand 但与 GIT_SSH_COMMAND= 一起工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49490767/