Home > Software design >  Why git clone works only in Powershell running as administrator?
Why git clone works only in Powershell running as administrator?

Time:06-20

I configure ssh key for my Gitlab account and want to git clone my repo, but cloning works only in Powershell running as administrator.

The command below works the same in both cases (with admin rights and without):

ssh -T [email protected]

The output is: Welcome to GitLab, @username!

How I can make to work git clone without running Powershell as administrator?


Update 1:
whoami output also the same for both cases (with admin rights and without)

Update 2:
git clone command error:

[email protected]: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Update 3:
git push command fails with the same error. Problem with access to private ssh key located in ~/.ssh/id_rsa ?

Update 4:
I set the default ssh command for git (ssh -Tv) as VonC suggested, but with this command:
git config --global core.sshCommand "ssh -Tv" (setting the GIT_SSH_COMMAND was not worked for me)
First 19 lines output for git pull command (no admin):

OpenSSH_8.8p1, OpenSSL 1.1.1m  14 Dec 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.gitlab.host.com [my.gitlab.host.ip] port 22.
debug1: Connection established.
debug1: identity file /t/.ssh/id_rsa type -1
debug1: identity file /t/.ssh/id_rsa-cert type -1
debug1: identity file /t/.ssh/id_dsa type -1
debug1: identity file /t/.ssh/id_dsa-cert type -1
debug1: identity file /t/.ssh/id_ecdsa type -1
debug1: identity file /t/.ssh/id_ecdsa-cert type -1
debug1: identity file /t/.ssh/id_ecdsa_sk type -1
debug1: identity file /t/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /t/.ssh/id_ed25519 type -1
debug1: identity file /t/.ssh/id_ed25519-cert type -1
debug1: identity file /t/.ssh/id_ed25519_sk type -1
debug1: identity file /t/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /t/.ssh/id_xmss type -1
debug1: identity file /t/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8

First 9 lines output for git pull command (admin):

OpenSSH_8.8p1, OpenSSL 1.1.1m  14 Dec 2021
debug1: Reading configuration data /c/Users/my_user/.ssh/config
debug1: /c/Users/my_user/.ssh/config line 1: Applying options for my.gitlab.host.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.gitlab.host.com [my.gitlab.host.ip] port 22.
debug1: Connection established.
debug1: identity file C:/Users/my_user/.ssh/id_rsa type 0
debug1: identity file C:/Users/my_user/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8

So it looks like in no-admin mode it even do not try to find keys/configs in right location. Any ideas of this behavior?

CodePudding user response:

In both instances (admin or no admin), set first:

set "GIT_SSH_COMMAND=ssh -Tv"

That way, you will see which key is accessed (from which folder), and you can compare both session.


It looks like in no-admin mode it even do not try to find keys/configs in right location.

What it does look like is, in no-admin mode, there is an environment variable HOME set to T:\ or /t.
Type set HOME in a CMD to confirm.

Setting that variable to %USERPROFILE% would mean using the right path.

  • Related