I am trying to connect to my local Gitea server. I have set it up to use the integrated SSH server on port 2222. I am running Windows. Gitea is running fine.
Now I want to connect using Cygwin's git. For testing the connection to my repository I am using the ls-remote command which works fine if I use the GIT_SSH_COMMAND
option like this:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa" git ls-remote --exit-code -h ssh://username@localhost:2222/username/Repo.git
Next I want to simplify life using ~/.ssh/config
:
host gitea
HostName localhost
Port 2222
IdentityFile ~/.ssh/id_rsa
User username
However, this does fail with error Unable to open connection
:
git ls-remote --exit-code -h ssh://gitea/username/Repo.git
Problem: IdentityFile
is not applied. This works:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa" git ls-remote --exit-code -h ssh://gitea/username/Repo.git
I am certain though, that my ~/.ssh/config
is correct, because connecting via directly ssh -vv gitea
works. Output (extract):
[...]
debug1: Connecting to localhost [::1] port 2222.
debug1: Connection established.
[...]
debug1: Offering public key: RSA SHA256:XXX /home/username/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp SHA256:XXX
debug1: Authentication succeeded (publickey).
Authenticated to localhost ([::1]:2222).
[...]
So why is git
not using IdentityFile
from ~/.ssh/config
?