简体   繁体   English

为什么 VS Code 终端总是询问我的 SSH 密码?

[英]Why does the VS Code terminal always ask for my SSH passphrase?

I'm using Ubuntu 20.10 and VS Code 1.52.1.我正在使用 Ubuntu 20.10 和 VS Code 1.52.1。 I followed GitHub's instructions to generate an SSH key, add it to the ssh-agent , and add it to my GitHub account .我按照 GitHub 的说明生成了一个 SSH 密钥,将其添加到 ssh-agent中,然后将其添加到我的 GitHub 帐户中。 When I use Ubuntu's built-in Terminal app, everything works correctly for repos that I clone with SSH:当我使用 Ubuntu 的内置终端应用程序时,对于我使用 SSH 克隆的存储库,一切正常:

git clone git@github.com:octocat/Spoon-Knife.git
cd Spoon-Knife
git fetch

It doesn't ask for my passphrase every time.它不会每次都要求我输入密码。 Similarly, if I open that cloned repo (or any other) in VS Code and run the Git: Fetch command (or Git: Push etc), it runs successfully without asking for my passphrase.同样,如果我在 VS Code 中打开克隆的仓库(或任何其他仓库)并运行Git: Fetch命令(或Git: Push等),它无需询问我的密码即可成功运行。

But when I run git fetch from the same directory inside of the VS Code integrated terminal, I get this message:但是当我从 VS Code 集成终端的同一目录中运行git fetch时,我收到以下消息:

Enter passphrase for key '/home/sam/.ssh/id_ed25519':

Even if I enter my passphrase for this invocation, it still keeps asking for my passphrase every time I run git fetch .即使我为此调用输入了密码,每次我运行git fetch时,它仍然会不断询问我的密码。 How can I fix this and make it act like the Ubuntu default terminal?我该如何解决这个问题并让它像 Ubuntu 默认终端一样工作? (I saw this question , but it seems to be for the VS Code UI rather than the integrated terminal, and none of the answers worked; most of them were steps that I had already followed as per the GitHub instructions linked above.) (我看到了这个问题,但它似乎是针对 VS Code UI 而不是集成终端,并且没有一个答案有效;其中大多数是我已经按照上面链接的 GitHub 说明执行的步骤。)

Check in your VS Code settings to see if you have Terminal › Integrated: Inherit Env unchecked:检查您的 VS Code 设置以查看您是否有终端 › 集成:未选中继承环境

将 inheritEnv 设置为 false 的设置 UI

If it is, re-check it:如果是,请重新检查:

将 inheritEnv 设置为 true 的设置 UI

Alternatively, use the Preferences: Open Settings (JSON) command to open your settings file and look for this line:或者,使用Preferences: Open Settings (JSON)命令打开您的设置文件并查找此行:

"terminal.integrated.inheritEnv": false

If it's present, remove it (since true is the default for that setting).如果存在,请将其删除(因为true是该设置的默认值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM