I cannot clone or push to a repository on my server.
I have a bare repo that is located is a directory user@host in directory home/user/test.git that I am trying to access via git clone. I used ssh-add <pathtokey> to add my ssh key. It asked me for the passphrase. I can then ssh user@host successfully.
However if I then try to git clone ssh://user@host/~/test.git I get:
Cloning into 'test'...
user@host: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
also tried
git clone ssh://user@host/home/user/test.gitgit clone user@host:home/user/test.gitgit clone user@host:/home/user/test.gitwith the same result
I am guessing the git credential manager isn't picking up the keys?
On the server /var/auth/log says
Feb 20 02:25:36 xxxxx sshd[24674]: Connection closed by authenticating user XXXX x.x.x.x port 56433 [preauth]
git version 2.30.1.windows.1Git Credential Manager version 2.0.318-beta+44acfafa98 (Windows, .NET Framework 4.0.30319.42000)git config -l reports credential.helper=manager-corePowerShell and git bash shells, same resultuser has read, execute permissions to the repoTo add to @VonC's response
In git-bash things work as normal.
The normal flow of starting the ssh-agent (via eval 'ssh-agent'
), adding the key via ssh-add <path_to_key> enables git clone to work.
In PowerShell Core, or Cmd, via Windows-Terminal more work is required
the ssh-agent starts automatically (assuming you previously started the OpenSSH Authentication Agent service), adding the key works, and you can ssh after this, but git commands do NOT work, initially, but if you do
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
This will replace the (default) ssh that comes with git-for-windows with the Windows10 implementation.
After this it should work fine in things other than git-bash. Confirmed in Powershell-Core, Command Prompt
See also: https://gist.github.com/danieldogeanu/16c61e9b80345c5837b9e5045a701c99
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With