lukesampson / pshazz

Give your powershell some pizazz.
The Unlicense
581 stars 40 forks source link

Prompting for password #110

Closed sebkolind closed 3 years ago

sebkolind commented 3 years ago

Hello,

I just installed Pshazz and everything works, except for the auto-storing of ssh keys. No matter what I've done the prompt for my password keeps appearing.

What I've tried is:

When I installed pshazz I was not prompted with a dialogue where I had to type in my password as stated here: https://scoop.netlify.app/guide/SSH-on-Windows.html#save-your-ssh-key-password-in-windows-credential-manager

And when running cmdkey /list:ssh:$home\.ssh\id_rsa I get a message of *NONE* in saved credentials.

What am I doing wrong here?

chawyehsu commented 3 years ago

askpass (and the dialogue) has been removed in favor of ssh-agent service, see here.

sebkolind commented 3 years ago

@chawyehsu Ok - but that does not change the fact that it does not work. I just ran: Get-Service ssh-agent and the ssh-agent is running, but I am still asked to type in my password when running git pull on a git repo.

And cmdkey /list:ssh:$home\.ssh\id_rsa still shows that I have no saved passwords - but that is maybe how it should be now that you are using ssh-agent instead?

chawyehsu commented 3 years ago

What's the credential helper you set in your gitconfig? Have you enabled Windows Credential Manager for git?

sebkolind commented 3 years ago

I ran the command in the documentation: git config --global credential.helper manager and here, again, you state that the dialogue should open, yet it does not. So I guess my git is not setup with Windows Credential Manager?

This is what I see when running git credential-manager config (together with other stuff): Effective Manager Configuration for file://localhost//: Executable = Git Credential Manager for Windows v1.20.0.0 (C:\Users\USERNAME\scoop\apps\git\2.30.0.windows.1\mingw64\libexec\git-core\git-credential-manager.exe)

Update

It turns out that ssh -T git@github.com works just fine after typing the password once, but all of my git repos (both GitHuband GitLab) keeps asking for my password.

chawyehsu commented 3 years ago

It turns out that ssh -T git@github.com works just fine after typing the password once, but all of my git repos (both GitHuband GitLab) keeps asking for the password.

Perhaps your git is not set up to work with ssh key, here is my ~/.ssh/config snippet.

Host *
  UseKeychain yes
  AddKeysToAgent yes
Host github.com
  Hostname ssh.github.com
  Port 443
  User git
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa

reference: https://stackoverflow.com/questions/10032461/git-keeps-asking-me-for-my-ssh-key-passphrase

chawyehsu commented 3 years ago

I'll close the issue if the above comment is helpful to you.

sebkolind commented 3 years ago

I added this to my config

Host *
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

But still nothing, unfortunately. The ssh-agent does not seem to save my passwords.

Note: UseKeychain yes is on macOS only, as far as I can see.

sebkolind commented 3 years ago

I found a solution! This guy: https://snowdrift.tech/cli/ssh/git/tutorials/2019/01/31/using-ssh-agent-git-windows.html mentions that you have to tell git to use the ssh-agent by running the last command in the blog post.

For reference if something happens to the blog, that command is: [Environment]::SetEnvironmentVariable("GIT_SSH", "$((Get-Command ssh).Source)", [System.EnvironmentVariableTarget]::User)

chawyehsu commented 3 years ago

Note: Using GIT_SSH to force git to use win32-openssh will probably create issues, https://github.com/git-for-windows/git/issues/2944

stefano-xy commented 3 years ago

I am the author of the issue linked above. Actually my point was that setting GIT_SSH to the OpenSSH implementation shipped with Windows solves the problem of the agent not being consulted. Where do you see that this approach creates other issues?

chawyehsu commented 3 years ago

@ragazzojp see another issue linked in your issue: https://github.com/git-for-windows/git/issues/2944#issuecomment-752252048 , pointing GIT_SSH to an older version of win32-openssh can hang Powershell.