1

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?

2
  • Can you create files in the clone directory without admin rights? What is the error message for git clone? Commented Jun 17, 2022 at 9:12
  • updated the question with error; yes I can create files/directories there without admins rights Commented Jun 17, 2022 at 9:18

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I checked the HOME variable on both modes with command: echo "HOME : $HOME" ; The output is the same: C:\Users\my_user
Ok, I do not know why, but when I have set additionally HOME variable with value C:\Users\my_user in environment variables - it have started to work.
@Egor $HOME only works in git bash. What about set HOME in CMD? Anyway, setting it explicitly is preferable indeed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.