Indrajit
Indrajit

Reputation: 2152

Unable to use git from Powershell 7.1 in Windows 10

I installed Git for Windows and Powershell 7.1. When I try to clone a repository from git bash using ssh key, it works perfectly. However when I try to do similar from Powershell 7.1, I get a fatal: Could not read from remote repository error.

Steps Followed

1. PS> Start-Service ssh-agent
2. PS> ssh-add D:\Keys\.ssh\my_private_key (I get identity added message)
3. PS> git clone [email protected]:my-username/my-repo.git

Error Message

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

Please make sure you have the correct access rights

Upvotes: 1

Views: 483

Answers (1)

VonC
VonC

Reputation: 1323115

That means ssh, in that Powershell session, is trying to look for SSH keys at %USERPROFILE% instead of D:\Keys

Check in your git bash if you have a ~/.ssh/config file which would specify the right private key to use for Host github.com.
And check what ~ (that is echo $HOME) resolves in said git bash session.
If should not be the same as the default HOME in a Powershell session, where git defaults to %USERPROFILE%

Upvotes: 2

Related Questions