microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.09k stars 29.26k forks source link

After VSCode is updated, git@github.com: Permission denied (publickey). #149622

Open oleksandrsv opened 2 years ago

oleksandrsv commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Update VSCode and restart
  2. In VSCode terminal: git pull
  3. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
oleksandrsv commented 2 years ago

workaround:

➜ iam git:(master) ssh-agent -s SSH_AUTH_SOCK=/var/folders/; export SSH_AUTH_SOCK; SSH_AGENT_PID=2942; export SSH_AGENT_PID; echo Agent pid 2942; ➜ iam git:(master) ls ~/.ssh/ config id_ed25519 id_ed25519.pub known_hosts ➜ iam git:(master) ssh-add ~/.ssh/id_ed25519 Identity added: //.ssh/id_ed25519 (@) ➜ iam git:(master) git pull remote: Enumerating objects remote: Counting objects remote: Compressing objects remote: Unpacking objects: From github.com:*

lszomoru commented 2 years ago

@oleksandrsv, were you able to permanently address the issue with the steps listed above? Thanks!

oleksandrsv commented 2 years ago

@lszomoru , yes, these commands have fixed git key issue after VSCode was updated today to version April 2022 (version 1.67)

lszomoru commented 2 years ago

@oleksandrsv, thank for the update. I will close the issue for now.

oleksandrsv commented 2 years ago

But why? Every time I update VSCode, I must re run commands for ssh agent?

lszomoru commented 2 years ago

@oleksandrsv, does this happen every time that you update VS Code?

oleksandrsv commented 2 years ago

@lszomoru , yes, that is why I am not updating VSCode often.

oleksandrsv commented 2 years ago

Same error today on new release of VSCode

Version: 1.67.2 Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 Date: 2022-05-17T18:20:57.384Z Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Darwin x64 21.5.0

oleksandrsv commented 2 years ago

Why Closed? This is bug in application.

richardvk commented 2 years ago

This still seems to be a problem. Workaround does not work for me.

lszomoru commented 2 years ago

@oleksandrsv, apologies for not getting back to you on this, as this issue for lost in my notifications. If I understand correctly, every time you are updating your VS Code instance you have to implement the workaround that you have listed above.

GraceWXT commented 2 years ago

@lszomoru I can't speak for the first question, since I'm not using Insiders. But for the second question, yes I see the same error whether I'm using the source control GUI, terminal, or command palette. And it's the same error for both push and pull.

NjaiJerreh commented 2 years ago

I am running into the same error still ? Please make sure you have the correct access rights and the repository exists.

oleksandrsv commented 2 years ago

@lszomoru Hi. I am using only stable releases. As I understand this issue is related to "lost" ssh key and when I add ssh key, everything works fine. Is it possible to add "startup scripts" to vscode? So that after update I will just add these lines and it will do workaround for me.

dage commented 2 years ago

I got the same error today when I tried to clone a github repo by copy-pasting the ssh uri (git@github.com:GITHUB_USER/REPO-NAME.git) into VSCode "Clone Git Repository..." uri-field.

If I instead did the following it works for me: 1.) Select "Clone Git Repository..." 2.) Click the "Clone from GitHub .... remote sources" link that appears bellow the "Provide repository URL or ...." field at the top. 3.) Wait a couple of seconds and then click the repo I want to clone.

pedrociarlini commented 1 year ago

Same problem here. Same workarround, also.

Version: 1.71.2 (Universal) Commit: 74b1f979648cc44d385a2286793c226e611f59e7 Date: 2022-09-14T21:05:37.721Z (2 mos ago) Electron: 19.0.12 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Darwin x64 19.6.0 Sandboxed: No

taras-clarifai commented 1 year ago

Same problem here

mapringg commented 1 year ago

I got the same problem and the workaround fixed it for me.

Version: 1.74.3 Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534 Date: 2023-01-09T17:05:47.808Z Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Darwin arm64 22.2.0 Sandboxed: No

fonnesbeck commented 1 year ago

This still happens to me using the version info below. I keep getting bugged for the ssh password and I occasionally get the "permission denied" error out of nowhere (not directly after supplying the password). I have also tried re-running eval "$(ssh-agent -s)"

Version: 1.76.2 Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884 Date: 2023-03-14T17:53:46.528Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin arm64 22.3.0 Sandboxed: No

varog-norman commented 1 year ago

Same problem after update to 1.78.0. Gotta use another terminal instead

clnunes commented 1 year ago

I have a similar issue, meaning if I use the terminal I am asked for the id pass and it works. (git pull) If I use the palette pull it never works even after using the terminal, I always got the Permission denied error.

lnickersl commented 1 year ago

For me It works from git bash and VS Code terminal, but Source Control "Sync Changes" button cannot find my key! Cannot find any Source Control ssh agent Settings

sik-asn commented 1 year ago

It seems like this issue is back.

I can do everything from the command-line, but the Git-integration is VSCode is not working, printing the following message:

> git pull --tags origin main
git@<REDACTED>: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
raraz15 commented 1 year ago

If I do not use Vscode Git extension and use a terminal outside, I can pull from git using SSH. I get the error only from Vscode.

rajamohan-gemini commented 1 year ago

Same issue for me as well. I can run all the git commands in terminal console. But when i use VS GUI method is failing to authenticate my public key.

zwilliamson-mf commented 11 months ago

Also seeing this issue. weirdly, in the output, I'm gettin the error "zwilliamson@github.com: Permission denied (publickey)", but that doesn't match my github username, or my email address on the account...not sure where that's coming from since its not in my public key

lszomoru commented 11 months ago

Can users that run into this error try to perform the same action from the Terminal? If the same error occurs when running the git command from the terminal it means that issue is not related to VS Code but the git configuration. GitHub has good documentation for troubleshooting this error - https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey.

Mr-Bojangles commented 11 months ago

I'm seeing this issue, as well. I can't perform any git actions from VS Code, either via the GUI or the integrated terminal. I have to use a completely separate terminal to run any git commands.

Version: 1.84.2 Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:52:33.687Z (3 wks ago) Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin x64 22.5.0

CataTudoran commented 9 months ago

My experience is that I am able to push and pull and everything in the integrated terminal, but when I try to use the GUI from source control, it does not work. I have a situation where I am using an enterprise github server. I have found that the problem is VSCode GUI searches for git-related configurations (i.e. gitconfig & ssh settings) within the user directory in Windows (C:\Users\.ssh for example). I have set the home directory to a custom one for my intents and purposes (internal company usage). This confuses the VSCode GUI as it cannot find any credentials whatsoever, although I had them set in my home gitconfig, this was the confusing part. As soon as I copied and pasted the gitconfig and the ssh within the user directory, everything was OK. Had I not done this, any actions within the source control of VSCode (fetch, pull, push) would have lead to a denial from GitHub (public key) and/or not being able to fetch for example the COMMIT_EDITMSG from the .github directory.

I think the bug is within the VSCode because it should look at the environment variables of windows for a HOME variable and extract the git configurations from there. This might be a particular use case of mine, but what I would encourage the users to look at is whether they have their configurations in the right location under the Users directory from C:\ drive.

Hope this helps!

FYI @lszomoru maybe this could be the underlying reason behind some of the other issues I have come across, such as https://github.com/microsoft/vscode/issues/114049, https://github.com/microsoft/vscode/issues/109660, https://github.com/microsoft/vscode/issues/110880, https://github.com/microsoft/vscode/issues/114433 or https://github.com/microsoft/vscode/issues/182412. It is somehow "covered" by the option git.requireGitUserConfig or other user-specific/OS configurations but it might be worth looking into it further.

GAZ082 commented 8 months ago

Same issue here (Linux). And also in Windows.

Version: 1.87.0 Commit: 019f4d1419fbc8219a181fab7892ebccf7ee29a2 Date: 2024-02-27T23:42:16.599Z Electron: 27.3.2 ElectronBuildId: 26836302 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Linux x64 6.7.6-arch1-2

Can you take a look at this @lszomoru

vamshisiram commented 8 months ago

same issue with vscode 1.87.1 image

Etra-0 commented 6 months ago

I get this a lot as well, started pretty recently. And sometimes starting a new terminal in VSCode does not fix it. I use VSCode for remote development through SSH. (Amazon Ubuntu EC2 instance). Latest VSCode version. It works fine with a separate terminal such as PowerShell outside of VSCode.

sik-asn commented 6 months ago

I figured out the problem was that my SSH-keys were mounted on a network-drive. As I'm on windows, the solution became to set a "HOME" environment-variable that points to my C-drive user-directory, and simply move my things to that drive.

This solved the issue with VSCode Git, but also sped up Bash and other CLI-tools significantly!

romanokarrafederico commented 4 months ago

I solved this problem to change the way that I opened the vscode here: image I already opened on wsl. If vscode ask you constantly your passphrase please close vscode and run on console: eval 'ssh-agent' ssh-add and then run code inside the git project Reference

augis91 commented 4 months ago

I had similar problem with my DevContainer after the VS Code update, so I've reopened the folder locally and then received a prompt from vs code's github, that I need to log. That solved my lost ssh key issue. I am on Mac OS 12.5 (intel Mac): Version: 1.90.0 Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573 Date: 2024-06-04T19:34:44.157Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin x64 21.6.0

hayashi80 commented 3 months ago

It seems that VSCode only recognize id_rsa/id_rsa.pub. When i rename ssh private key to id_rsa/id_rsa.pub, it solved.

kyrlon commented 1 month ago

I am still having this issue now on the latest update.