Skip to content

Unable to Persist Credentials and Not Getting Prompted for Auth #633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gbrac opened this issue Mar 18, 2022 · 17 comments
Closed

Unable to Persist Credentials and Not Getting Prompted for Auth #633

gbrac opened this issue Mar 18, 2022 · 17 comments

Comments

@gbrac
Copy link

gbrac commented Mar 18, 2022

When pushing or pulling to Azure DevOps git repo, I do not get prompted for credentials and it fails. Running git-credential-manager-core diagnose, I get: System.Exception: Unable to persist credentials with the 'wincredman' credential store.

OK ] Environment
[ OK ] File system
[ OK ] Networking
[ OK ] Git
[FAIL] Credential storage

[!] Encountered an exception [!]
System.Exception: Unable to persist credentials with the 'wincredman' credential store.

See https://aka.ms/gcm/credstores for more information.

   at GitCredentialManager.CredentialStore.ValidateWindowsCredentialManager()

   at GitCredentialManager.CredentialStore.EnsureBackingStore()

   at GitCredentialManager.CredentialStore.Remove(String service, String account)

   at GitCredentialManager.Diagnostics.CredentialStoreDiagnostic.RunInternalAsync(StringBuilder log, IList`1 additionalFiles)

   at GitCredentialManager.Diagnostics.Diagnostic.<RunAsync>d__5.MoveNext()

[*] Diagnostic test log [*]
ICredentialStore instance is of type: CredentialStore

Writing test credential...Deleting test credential...

[ OK ] Microsoft authentication (AAD/MSA)
[ OK ] GitHub API

Diagnostic summary: 6 passed, 0 skipped, 1 failed.

@Elsewhere42
Copy link

I'm experiencing something similar with 2.35.1.Windows.2

I downgraded to 2.35.0.Windows.1 and that fixed the issue.
https://github.com/git-for-windows/git/releases/tag/v2.35.0.windows.1

I suspect there is a critical bug in 2.35.1.Windows.2.

Opening repositories:
C:\Users\[username]\Source\Repos\[myRepoName]
Pushing develop
git: 'credential-manager' is not a git command. See 'git --help'.

The most similar command is
	credential-manager-core
Error encountered while pushing to the remote repository: Git failed with a fatal error.
Git failed with a fatal error.
Unable to persist credentials with the 'wincredman' credential store.
See https://aka.ms/gcm/credstores for more information.
cannot spawn askpass: No such file or directory
could not read Password for 'https://my.git.repository.url': terminal prompts disabled

Failed to push to the remote repository. See the Output window for more details. 

@gbrac
Copy link
Author

gbrac commented Mar 23, 2022

Thanks. I tried downgrading to this version, but the issue remains for me.

@Elsewhere42
Copy link

Well... mine is not working again. Now with a new error:

Cloning into 'C:\Users\[username]\Source\Repos\MyRepoName'...
Error encountered while cloning the remote repository: Git failed with a fatal error.
Unable to persist credentials with the 'wincredman' credential store.
See https://aka.ms/gcm/credstores for more information.
Unable to persist credentials with the 'wincredman' credential store.
See https://aka.ms/gcm/credstores for more information.
Unable to persist credentials with the 'wincredman' credential store.
See https://aka.ms/gcm/credstores for more information.
cannot spawn askpass: No such file or directory
could not read Password for 'https://[email protected]/MyGitPath': terminal prompts disabled

This is killing me. I'm dead in the water. Git is 100% unusable.

@ldennington
Copy link
Contributor

@gbrac @Elsewhere42 - Are you SSH'ing into your Windows machines by chance?

@gbrac
Copy link
Author

gbrac commented Mar 24, 2022

No, I am not.

@ldennington
Copy link
Contributor

ldennington commented Mar 24, 2022

@Elsewhere42 - I'm assuming you also were not prompted to authenticate? Would you both mind running the below command, re-running your push/clone commands to repro the issue, then dropping the log file that was created in your %USERPROFILE% directory (redacted where appropriate) here?

SET GCM_TRACE=%USERPROFILE%\gcm.log

@Elsewhere42
Copy link

@ldennington Thanks for the tip about the log file. Over several days I spent many hours searching for a logging command but never found one. That was exactly what I needed.

git-credential-manager-core diagnose

It looks like a Proxy Authentication error. Is there any information available about how to setup Proxy Authentication on Git?

------------
Diagnostic: GitHub API
Skipped: False
Success: False
Exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.GitHubRestApi.<GetMetaInfoAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.Diagnostics.GitHubApiDiagnostic.<RunInternalAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitCredentialManager.Diagnostics.Diagnostic.<RunAsync>d__5.MoveNext()

@ldennington
Copy link
Contributor

ldennington commented Mar 24, 2022

Would you mind trying the steps outlined here?

@gbrac
Copy link
Author

gbrac commented Mar 25, 2022

This is the only error or exception I have in that log. Everything else reports OK:

------------
Diagnostic: Credential storage
Skipped: False
Success: False
Exception:
System.Exception: Unable to persist credentials with the 'wincredman' credential store.
See https://aka.ms/gcm/credstores for more information.
   at GitCredentialManager.CredentialStore.ValidateWindowsCredentialManager()
   at GitCredentialManager.CredentialStore.EnsureBackingStore()
   at GitCredentialManager.CredentialStore.Remove(String service, String account)
   at GitCredentialManager.Diagnostics.CredentialStoreDiagnostic.RunInternalAsync(StringBuilder log, IList`1 additionalFiles)
   at GitCredentialManager.Diagnostics.Diagnostic.<RunAsync>d__5.MoveNext()
Log:
ICredentialStore instance is of type: CredentialStore
Writing test credential...Deleting test credential...
------------

@ldennington
Copy link
Contributor

ldennington commented Mar 25, 2022

@gbrac - apologies! I edited my above comment. Would you mind following the new instructions and sending along those logs?

@ldennington
Copy link
Contributor

@ldennington Thanks for the tip about the log file. Over several days I spent many hours searching for a logging command but never found one. That was exactly what I needed.

git-credential-manager-core diagnose

It looks like a Proxy Authentication error. Is there any information available about how to setup Proxy Authentication on Git?

------------
Diagnostic: GitHub API
Skipped: False
Success: False
Exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.GitHubRestApi.<GetMetaInfoAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.Diagnostics.GitHubApiDiagnostic.<RunInternalAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitCredentialManager.Diagnostics.Diagnostic.<RunAsync>d__5.MoveNext()

For future reference, you can find details on troubleshooting (including logging) here.

@gbrac
Copy link
Author

gbrac commented Mar 25, 2022

I attempted to do the git push from the command line (instead of from within Visual Studio Pro 2022), and it appears to work. So, the issue appears to involve Visual Studio and GCM Core. I previously had GCM for Windows (the non-core version), and that worked, other than it would ask for credentials every time (instead of caching them). It appears now that only GCM Core is available, however.

@mjcheetham
Copy link
Collaborator

[..] and that worked, other than it would ask for credentials every time (instead of caching them). It appears now that only GCM Core is available, however.

This will be the same underlying problem. GCM for Windows will have been prompting you each time because it was failing to persist credentials in the store. GCM (Core) is instead failing up-front because it has detected persistence is broken for some reason.

Please can you try changing the backing store that is being used to one that is more reliable?

git config --global credential.credentialStore dpapi

This will tell GCM to write credentials to encrypted files under %USERPROFILE%\.gcm\dpapi_store rather than use the Windows Credential Manager store (which is seemingly not working for you).

@realSAH
Copy link

realSAH commented May 11, 2023

@gbrac @Elsewhere42 - Are you SSH'ing into your Windows machines by chance?

Yes, I am SSHing to a windows machine. Everything works seamlessly when I RDP to the remote. But when I SSH, it says unable to presiste credentials.

Could you please let us know how to solve it in SSH case?

@realSAH
Copy link

realSAH commented May 11, 2023

After a little bit of reading, it turns out that docs explicitly warn that wincredsman codesn't work for SSH and advise for a different one instead.

https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/credstores.md

@Gmanunta81GFPS
Copy link

[..] and that worked, other than it would ask for credentials every time (instead of caching them). It appears now that only GCM Core is available, however.

This will be the same underlying problem. GCM for Windows will have been prompting you each time because it was failing to persist credentials in the store. GCM (Core) is instead failing up-front because it has detected persistence is broken for some reason.

Please can you try changing the backing store that is being used to one that is more reliable?

git config --global credential.credentialStore dpapi

This will tell GCM to write credentials to encrypted files under %USERPROFILE%\.gcm\dpapi_store rather than use the Windows Credential Manager store (which is seemingly not working for you).

it fixed my issue that it "Unable to persist credentials with the 'wincredman' credential store."

@DanWaheed
Copy link

[..] and that worked, other than it would ask for credentials every time (instead of caching them). It appears now that only GCM Core is available, however.

This will be the same underlying problem. GCM for Windows will have been prompting you each time because it was failing to persist credentials in the store. GCM (Core) is instead failing up-front because it has detected persistence is broken for some reason.
Please can you try changing the backing store that is being used to one that is more reliable?

git config --global credential.credentialStore dpapi

This will tell GCM to write credentials to encrypted files under %USERPROFILE%\.gcm\dpapi_store rather than use the Windows Credential Manager store (which is seemingly not working for you).

it fixed my issue that it "Unable to persist credentials with the 'wincredman' credential store."

I had this same issue and this resolved my issue as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants