I can clone my repo from github using ssh, but can't fetch or push. I'm using an ssh config with a host entry, named gh-personal, that points to github.com and provides my pubkey.
Furthermore, the usual debugging technique, setting GIT_SSH_COMMAND to "ssh -v," causes the fetches and pushes to WORK.
The clone works:
$ git clone git@gh-personal:dgentry/myDotfiles
Cloning into 'myDotfiles'...
remote: Enumerating objects: . . . .
Resolving deltas: 100% (3570/3570), done.
The fetch immediately after fails:
$ cd myDotfiles/
$ git fetch
ssh: Could not resolve hostname gh-personal: Temporary failure in name resolution
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Set GIT_SSH_COMMAND in an attempt at debugging, and it works:
$ GIT_SSH_COMMAND="ssh" git fetch
$ # This works
All I can figure is that git is using some kind of internal ssh by default, and that ssh isn't looking up my .ssh/config entry for gh-personal.
(There's more weirdness. If I clone the repo into a directory whose name doesn't match the repo name, fetch/push works normally.)
And, for reference, here's the ~/.ssh/config entry for gh-personal:
Host gh-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github
IdentitiesOnly yes
AddKeysToAgent yes
Does anyone know how to make this work always?
Check if you have any environment variable related to SSH, by typing
set
.And if your
PATH
references the anotherssh
before the Git one.Note the URL can be
gh-personal:dgentry/myDotfiles
, no need forgit@
, since theUser
is part of yourgh-personal
entry in your ~/.ssh/config.To be safe, make sure you are testing this with the latest Git version you can upgrade to.