3

when I search the problem online, people always want to get rid of the ssh key passphrase prompt, but I have an opposite problem.

I am NOT using ssh-agent, and want windows to prompt ssh key passphrase everytime when I connect to the ssh server. It works fine with ssh command in powershell. But when I use git clone ssh://myserver/repo.git, there is no ssh key passphrase prompt and the connection is simply failed. I tried Powershell 5.x and 7.x and both gave me the same result:

> git clone ssh://myserver/repo.git
Cloning into 'repo'...
myserver: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

1 Answer 1

1

To let git prompt ssh key passphrase in powershell, The environment variable GIT_SSH has to be set to C:\Windows\System32\OpenSSH\ssh.exe. After setting up this environment variable, powershell has to be restarted to use it.

You can either add the environment variable in Control Panel, or execute the following commands in powershell:

$SSHPath = (Get-Command -Name 'ssh.exe').Source
[Environment]::SetEnvironmentVariable('GIT_SSH', $SSHPath, 'User')

To verify you have successfully setup this environment variable, do the following in powershell:

> echo $env:git_ssh
C:\Windows\System32\OpenSSH\ssh.exe

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .