I was using SSH to clone a git repo with Windows; however in PowerShell.
$configStoreGitDir = "$GitBaseDir\.git" if (!(Test-Path -Path $configStoreGitDir -PathType Container)) { Write-Verbose "Unable to locate local git folder at $GitBaseDir - recreating and cloning" New-Item -Type Directory $GitBaseDir git clone $GIT_REPO $GitBaseDir }
When I was trying to clone a repo as a user I was getting the same .ssh directory error:
Cloning into 'C:\Git\test-environments'... Could not create directory '/c/Windows/system32/.ssh'.
Instead of hardcoding the path, I set the Powershell environment variable $env:USERPROFILE to use HOME just like @akevit mentioned in his answer.
$env:HOME = $env:USERPROFILE $configStoreGitDir = "$GitBaseDir\.git" if (!(Test-Path -Path $configStoreGitDir -PathType Container)) { Write-Verbose "Unable to locate local git folder at $GitBaseDir - recreating and cloning" New-Item -Type Directory $GitBaseDir git clone $GIT_REPO $GitBaseDir }
Now it works and uses the known_hosts and id_rsa private key in the users $env:USERPROFILE\.ssh\ directory.
Cloning into 'C:\Git\test-environments'... remote: Counting objects: 460, done. remote: Compressing objects: 100% (457/457), done.
This was with the latest Windows 64bit git install:
git --version git version 2.6.3.windows.1
SYSTEMuser. Why?