vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Support GitHub Desktop authentication

Open joe912 opened this issue 11 years ago • 28 comments

I have scm git installed and GitHub for Windows.

When I try to push I get prompted for username/password then get "Authentication failed on the git remote."

I am able to push from GitHub for Windows and command line using same credentials

joe912 avatar Nov 23 '15 12:11 joe912

What do you get when running git remote -v?

joaomoreno avatar Nov 23 '15 14:11 joaomoreno

Hi, opening GIT bash in the folder & running I get $ git remote -v origin https://github.com/joe912/taggle.git (fetch) origin https://github.com/joe912/taggle.git (push)

joe912 avatar Nov 23 '15 21:11 joe912

Yeah this is known. Hope you don't mind that I renamed this issue.

joaomoreno avatar Nov 24 '15 08:11 joaomoreno

GitHub Desktop clones every repository using the https protocol and creates ~/.ssh/github_rsa and ~/.ssh/github_rsa.pub which it somehow uses for auth. git (or ssh) by default only looks for ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub when using authentication.

We need to:

  • [ ] Find out how GitHub Desktop is able to use pubkey auth with the https protocol
  • [ ] Make VSCode use that github_rsa key when pulling/pushing from a GitHub repository.

joaomoreno avatar Nov 24 '15 08:11 joaomoreno

ok - thanks for the update

joe912 avatar Nov 24 '15 12:11 joe912

I can confirm I am having this same issue. I can use GitHub Desktop or CLI to push, but I can not sync with VS Code. I tried again with the December update and it was not supported still.

khrome83 avatar Dec 20 '15 01:12 khrome83

I found the following Stackoverflow post that solved this issue.

Basically, I ran git config --global credential.helper wincred from the command line, and restarted VC Code. When I reopened the project, I was now able to sync from VS Code.

Do not know how this persists, and if it is only for that repo (--global makes me thing it will work elsewhere).

Can we run this command as part of installation, if this solves the issue?

khrome83 avatar Dec 20 '15 01:12 khrome83

Hello, I'm having the same issues, already followed the Stackoverflow post but it didn't work.

I don't have any problem with editing the code in VSC and then using the CLI or the GitHub desktop to sync my repos but It would be great if this issue is solved, the last update didn't solved it.

thanks

mgs96 avatar Dec 24 '15 06:12 mgs96

Hi, I'm experience this issue too. I'm willing to help. Please let me know how.

jamesxv7 avatar Dec 28 '15 18:12 jamesxv7

I can elaborate on what is causing issue for people.

If GitHub desktop is opened, it will break VS Code ability to push/pull. Closing GitHub desktop, DOES NOT fix VS Code GitHub sync.

Instead you have to -

  1. Close GitHub Desktop and VS Code.
  2. Run git config --global credential.helper wincred from Powershell or Cmd.
  3. Reopen VS Code, you now have ability to push/pull without entering in username and password.

Opening GitHub Desktop will break this. There seems to be a conflict of some sort that is causing this issue.

khrome83 avatar Jan 01 '16 04:01 khrome83

@khrome83 I tried several times your workaround and it is not working.

jamesxv7 avatar Jan 03 '16 01:01 jamesxv7

I was having this exact problem. Closing GitHub Desktop and running the config command did nothing for me. I started backtracking and remembered that I had recently added a simple .gitattributes file.

Most of the file was simply comments, and once I removed it and followed the instructions above once again, things started working. Every time I open the desktop app, it breaks again. But at least the aforementioned fix works as long as I don't add this file to the project.

# # Auto detect text files and perform LF normalization
# *        text=auto
# 
# *.cs     text diff=csharp
# *.java   text diff=java
# *.html   text diff=html
# *.css    text
# *.js     text
# *.sql    text
# 
# *.csproj text merge=union
# *.sln    text merge=union eol=crlf
# 
# *.docx   diff=astextplain
# *.DOCX   diff=astextplain
# 
# # absolute paths are ok, as are globs
# /**/postinst* text eol=lf
# 
# # paths that don't start with / are treated relative to the .gitattributes folder
# relative/path/*.txt text eol=lf

* text=auto

Looks like the age old battle between \n & \r\n has returned to bite us once again ;) JK, I don't know if it's related. But that is the only thing this settings file should have affected.

djabraham avatar Jan 16 '16 12:01 djabraham

Why would having the file offer a conflict if the issue is just credentials? Is it because it is a conflict with the rules within VS Code (LF / CRLF). This is very confusing, but it does make sense. I did not have this file.

Is the solution to make VS Code sensitive to this file for it's GIT Implementation?

khrome83 avatar Jan 16 '16 15:01 khrome83

May not be related at all, really. One this is pretty clear, when VSCode sends credentials manually via a prompt (in Windows only?), it simply doesn't work. So the easiest way to fix it is to eliminate the prompt, and that is what the command above seems to do. I did see some strange formatting in the git settings file too, but it may be unrelated. This is a file that seems to get touched when you open github desktop though.

git config --global --e

Opens the following file for me..(noticed multiple credential headings)

[user]
        name = djabr..
        email = <redacted>
[filter "lfs"]
        clean = git-lfs clean %f
        smudge = git-lfs smudge %f
        required = true
[credential]
[credential]
[credential]
        helper = wincred

djabraham avatar Jan 16 '16 16:01 djabraham

Hi For those who still have this problem, this worked for me https://social.msdn.microsoft.com/Forums/vstudio/en-US/eb6853f3-b710-4be5-8b82-d55fa568e2b9/problem-with-git-on-vs-code?forum=vsarch

Regards

meelosh94 avatar Feb 02 '16 11:02 meelosh94

Hi~I have this problems as well. I'm using Coding instead of GitHub. Is it because of https protocol? How can I make the same credentials work in vs code?

0NG avatar Jul 25 '17 05:07 0NG

Step 1 in your project folder run start-ssh-agent Step 2 add your id_rsa or whatever name of your private RSA key password Step 3 in the same directory open the cmd or power shell and run code

ghost avatar Jan 24 '18 21:01 ghost

this "git config --global credential.helper wincred" might work on windows, but I'm using a mac and Microsoft forces anyone on their repositories to activate 2 factor authentication.

I cannot login from VSCode to my GitHub in order to sync with origin.

Does anyone have a workaround for a Mac?

shaipetel avatar Mar 29 '18 19:03 shaipetel

Since I don't want to Hijack this thread for Mac, I opened a separate issue for Mac OS: https://github.com/Microsoft/vscode/issues/46964

shaipetel avatar Mar 29 '18 19:03 shaipetel

FYI found a workaround that seems to work on all OS systems, Mac and Windows: Visit your github developer settings and generate a personal access token.

That token can be used as your password with your user name to login from VSCode and it seems to work normally from that point on without any special configuration.

shaipetel avatar Apr 09 '18 15:04 shaipetel