I’m trying to configure git with GitHub on my Windows 7 computer using PowerShell instead of the usual bash terminal. I keep getting authentication errors when trying to connect.
Here’s what I’ve done so far:
Installed the portable version of msysgit
Used ssh-keygen from C:\program files\git\bin to create SSH keys in c:\Temp
Made a .ssh folder in c:\Users\myusername
Copied both id_rsa and id_rsa.pub files to the .ssh folder
Added the public key content to my GitHub account settings
Set up git alias in PowerShell: set-alias git ‘C:\program files\git\bin\git.exe’
When I try cloning with [email protected]:myrepo/test-project.git I get:
Permission denied (publickey)
fatal: The remote end hung up unexpectedly
I think git isn’t finding my SSH keys properly. Also when I run git config --global user.name "John Smith" I get fatal: $HOME not set even though I created a HOME environment variable with %HOMEDRIVE%%HOMEPATH%.
What am I missing to make this work with PowerShell?
powershell on win 7 can be a pain with ssh. set your git_ssh variable like this: $env:GIT_SSH = "C:\Program Files\Git\bin\ssh.exe". check your ssh key permissions too - windows screws this up all the time. you might need to generate the key pair directly in your .ssh folder rather than copying it from somewhere else.
Your SSH agent isn’t properly set up for Git in PowerShell. I ran into this same issue on Windows 7 - just copying keys doesn’t work. You need the SSH agent running and loaded with your keys.
First, run ssh-add C:\Users\yourusername\.ssh\id_rsa in PowerShell to add your private key. If that fails, start the SSH agent first with ssh-agent.
For the HOME variable, skip the Windows environment settings. Instead, add $env:HOME = "C:\Users\yourusername" directly to your PowerShell profile. This worked way better for me than system variables.
Also check if SSH is using the right key location. Run ssh -vT [email protected] to see which keys it’s trying during authentication.
Windows 7 PowerShell SSH is a total nightmare. I’ve wasted hours on manual key setup and environment variables that break constantly.
I gave up and built an automation workflow using Git API calls instead. Way more reliable than SSH on old Windows.
Just authenticate with GitHub using personal access tokens, then handle clone/push/pull through their REST API. No SSH agent mess, no path problems, no Windows permission hell.
I use this for all my legacy Windows boxes now. Takes 5 minutes vs hours of SSH debugging. The workflow syncs multiple repos and handles branches automatically.
Your auth becomes bulletproof - no dependence on Windows SSH or PowerShell weirdness. Clean API calls that actually work.