简体   繁体   English

OSX 上的 VScode - GIT ssh 密钥密码 - 从终端中的构建工作而不是从命令面板

[英]VScode on OSX - GIT ssh key passphrase - working from build in terminal put not from command palette

I can connect to the Git server and do anything I want from the VSCode build in terminal, but, as soon as I use the command pallette and want to perform a push, it fails as now passphrase prompt is shown.我可以连接到 Git 服务器并从终端中的 VSCode 构建做任何我想做的事情,但是,一旦我使用命令面板并想要执行推送,它就会失败,因为现在显示密码提示。

Is there any way to avoid entering the passphrase at each push?有什么办法可以避免在每次推送时输入密码?

That seems expected considering the Remote Development Tips and Tricks section:考虑到远程开发提示和技巧部分,这似乎是意料之中的:

Enabling alternate SSH authentication methods#启用备用 SSH 身份验证方法#

If you are connecting to an SSH remote host and are either:如果您连接到 SSH 远程主机并且是:

  • Connecting with two-factor authentication连接两因素身份验证
  • Using password authentication使用密码验证
  • Using an SSH key with a passphrase when the SSH Agent is not running or accessible当 SSH 代理未运行或无法访问时,使用带有密码的 SSH 密钥

then VS Code should automatically prompt you to enter needed information.然后 VS Code 应该会自动提示您输入所需的信息。 I

So make sure the SSH agent is running locally所以请确保SSH 代理在本地运行

VS Code will automatically add your key to the agent so you don't have to enter your passphrase every time you open a remote VS Code window. VS Code 会自动将您的密钥添加到代理,因此您不必每次打开远程 VS Code window 时都输入密码。

To verify that the agent is running and is reachable from VS Code's environment, run ssh-add -l in the terminal of a local VS Code window.要验证代理是否正在运行并且可以从 VS Code 的环境访问,请在本地 VS Code window 的终端中运行ssh-add -l
You should see a listing of the keys in the agent (or a message that it has no keys).您应该会看到代理中的密钥列表(或它没有密钥的消息)。
If the agent is not running, follow these instructions to start it.如果代理未运行,请按照以下说明启动它。 After starting the agent, be sure to restart VS Code.启动代理后,一定要重启 VS Code。

to make it work I had to ad the key to OSX keychain and configure it in.ssh/config为了使它工作,我必须将密钥添加到 OSX 钥匙串并在.ssh/config 中配置它

Automatically load keys into the ssh-agent and store passphrases in the keychain : (see step 2) 自动将密钥加载到 ssh-agent 并将密码短语存储在钥匙串中:(请参阅第 2 步)

If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.如果您使用的是 macOS Sierra 10.12.2 或更高版本,您将需要修改您的 ~/.ssh/config 文件以自动将密钥加载到 ssh-agent 并将密码短语存储在您的钥匙串中。

First, check to see if your ~/.ssh/config file exists in the default location.首先,检查您的 ~/.ssh/config 文件是否存在于默认位置。

$ open ~/.ssh/config
> The file /Users/YOU/.ssh/config does not exist.

If the file doesn't exist, create the file.如果该文件不存在,则创建该文件。

$ touch ~/.ssh/config

Open your ~/.ssh/config file, then modify the file to contain the following lines.打开 ~/.ssh/config 文件,然后修改该文件以包含以下行。 If your SSH key file has a different name or path than the example code, modify the filename or path to match your current setup.如果您的 SSH 密钥文件的名称或路径与示例代码不同,请修改文件名或路径以匹配您当前的设置。

Host *.github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

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

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