4

I would like to use the config to set sshCommand instead of the environment variable. But does not work Here is what happens

➜  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.

And debugging, it does not use the value from 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'\'''

Versions

➜  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
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Gunstick
  • 993
  • 10
  • 15

1 Answers1

10

The core.sshCommand option was added to git 2.10.0. You're running 2.7.4, which doesn't have that functionality. You'd need to upgrade to a newer Git if you wanted to use it.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • 2
    I tried `ENV` approach with `export GIT_SSH_COMMAND` and config approach with `git config --global core.sshCommand`, both failed. Turns out `docker` image I'm using was based on `debian/jessie` and it had `git 2.1` . I was troubleshooting the wrong place for HOURS!. Thanks @brian –  Jul 06 '18 at 15:08
  • Setting the env var `GIT_TRACE=1` will show the ssh command git is calling. – Marco Aurelio Jun 08 '22 at 22:27