Puvox – Blog

[SOLUTION] CMD & TortoiseGit: “Please make sure you have the correct access rights”

Solving CMD authorization for git commands

 

If in your TortoiseGit GUI everything works well, but when running git commands directly from CMD, you get:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

Then one of the possible solutions, you might try is to set “GIT_SSH” for terminal (cmd or powershell) session only at first:

// this is package.json example, just replace "reponame" & "branchname"
{
  "scripts": {
    "PULL-MASTER": "powershell -Command \"$Env:GIT_SSH='C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitPlink.exe'; cd c; git.exe pull --progress -v --no-rebase reponame branchname\""
  }
}

Warning: do not use any of the following approaches for this case:

[System.Environment]::SetEnvironmentVariable("GIT_SSH", "", "User") // or Machine
 //// or ///
git config --global core.sshCommand "tortoiseplink -agent" 
git config --global --unset core.sshCommand

because the first one amends environment variable and second one saves into `%userprofile%\.gitconfig` file and remove that entry.

 

Exit mobile version