git 如何在 IntelliJ IDEA 中存储 SSH 主机密钥

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6746746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:22:38  来源:igfitidea点击:

How to store SSH host key in IntelliJ IDEA

gitsshintellij-ideakey

提问by akaIDIOT

When using SSH as the connection for IDEA's git integration, IDEA keeps asking to store the host's rsa signature in the host key database. Pressing Yes works, but does not store the key in a database, the next time the connection is used, IDEA comes with the same question. Pressing No makes the connection fail.

当使用 SSH 作为 IDEA 的 git 集成连接时,IDEA 不断要求将主机的 rsa 签名存储在主机密钥数据库中。按 Yes 有效,但不会将密钥存储在数据库中,下次使用连接时,IDEA 会出现同样的问题。按 No 会使连接失败。

I can't seem to find any configuration for IDEA's SSH connectivity, nor does google supply any useful results... Any thoughts on how to get rid of the key store dialogue?

我似乎找不到 IDEA 的 SSH 连接的任何配置,谷歌也没有提供任何有用的结果......关于如何摆脱密钥存储对话的任何想法?

Using:

使用:

IntelliJ IDEA 10.5.1 with JDK 1.6.0_22 on Windows XP

Windows XP 上的 IntelliJ IDEA 10.5.1 和 JDK 1.6.0_22

MySysGit 1.7.6 with both its bin/ and mingw/bin folders in %PATH%

MySysGit 1.7.6 及其 bin/ 和 mingw/bin 文件夹位于 %PATH%

"git.exe" as the git executable in IDEA

“git.exe”作为IDEA中的git可执行文件

"IDEA ssh" as the SSH Executable in IDEA

“IDEA ssh”作为IDEA中的SSH可执行文件

openssh-server 1:5.5p1-6 (Debian Squeeze) on the server side

服务器端的 openssh-server 1:5.5p1-6 (Debian Squeeze)

采纳答案by akaIDIOT

It seems Windows does not let IDEA change your personal settings as easily as one would expect. Making sure the host signature can be saved fixes the issue. To let IDEA do this, run IDEA as Administrator on Vista/Win7 or unset the "Protect my computer from unauthorized program activity" in XP's Run Asdialog just once. After making an SSH connection and saving the signature this fixes the annoying dialog. After saving the signature, IDEA accepts the host even when run as a mortal user.

似乎 Windows 并没有让 IDEA 像预期的那样轻松更改您的个人设置。确保可以保存主机签名可以解决此问题。要让 IDEA 执行此操作,请在 Vista/Win7 上以管理员身份运行 IDEA 或在 XP 的运行方式对话框中取消设置“保护我的计算机免受未经授权的程序活动”一次。在建立 SSH 连接并保存签名后,这修复了烦人的对话框。保存签名后,即使以普通用户身份运行,IDEA 也会接受主机。

回答by Cameron Stone

I just had the same problem with IDEA 13 on Win7, and it was solved by switching to "Native" SSH executable in the Git Settings page. I did that while running Intellij as administrator as suggested by the accepted answer, but the accepted answer didn't fix the problem untilI changed the SSH executable.

我刚刚在 Win7 上的 IDEA 13 遇到了同样的问题,通过在 Git 设置页面中切换到“本机”SSH 可执行文件来解决。我在按照接受的答案的建议以管理员身份运行 Intellij 时这样做了,但是在我更改了 SSH 可执行文件之前,接受的答案并没有解决问题。

回答by ?eljko Trogrli?

I had same issue with IDEA 13 and 14. By default, IDEA will try to create/access .ssh/known_hostsfile in %HOME% directory.

我在 IDEA 13 和 14 中遇到了同样的问题。默认情况下,IDEA 将尝试.ssh/known_hosts在 %HOME% 目录中创建/访问文件。

However, %HOME% was not defined on my system (Windows 7 Enterprise x64). IDEA wouldn't store key; rather, it would ask for it for every operation.

但是,我的系统(Windows 7 Enterprise x64)上没有定义 %HOME%。IDEA 不会存储密钥;相反,它会在每次操作时都要求它。

When I defined %HOME% (%HOME% = %HOMEDRIVE%in my case), everything worked as advertised.

当我定义 %HOME% (%HOME% = %HOMEDRIVE%在我的例子中)时,一切都如宣传的那样工作。

This is a confirmed bugin IDEA; it should search:

这是IDEA 中已确认的错误;它应该搜索:

  • %HOME%
  • %HOMEDRIVE%
  • %HOMEPATH%
  • %USERPROFILE%
  • %家%
  • %HOMEDRIVE%
  • %家庭路径%
  • %用户资料%

Check also this issue.

也检查这个问题

回答by antoine

I also have mSysGit and I have put "C:\Program Files (x86)\Git\bin"on the PATH.

我也有 mSysGit 并且我已经设置"C:\Program Files (x86)\Git\bin"了 PATH。

There are at least two problems when using IntelliJ together with mSysGit and the ssh protocol with private/public keys :

将 IntelliJ 与 mSysGit 和带有私钥/公钥的 ssh 协议一起使用时,至少存在两个问题:

IntelliJ does not know how to bring up the message about "The authenticity of host ... can't be established" so yes it helps to run the git command once by hand to get the .ssh/known_hostsfile updated.

IntelliJ 不知道如何显示关于“主机的真实性......无法建立”的消息,所以是的,它有助于手动运行一次 git 命令以.ssh/known_hosts更新文件。

mSysGit when it is started directly outside of the "Git Bash" does not "know" where your home directory is and uses as .ssh folder "C:\Program Files\Git\.ssh".

当 mSysGit 直接在“Git Bash”之外启动时,它不会“知道”您的主目录在哪里并用作 .ssh 文件夹"C:\Program Files\Git\.ssh"

I am wondering whether setting a HOME environment variable pointing to one's Windows home directory would help. Adding to the confusion, different tools have a different notion of where your home directory lives.

我想知道设置一个指向 Windows 主目录的 HOME 环境变量是否会有所帮助。更令人困惑的是,不同的工具对主目录所在的位置有不同的概念。

  • Cygwin thinks my home directory is under C:\Users\myself\AppData\Roaming.
  • Java apps think my home directory is under C:\Users\myself
  • my network home drive is H:\ on the corporate network and some tools think my real home is H:\
  • Cygwin 认为我的主目录在C:\Users\myself\AppData\Roaming.
  • Java 应用程序认为我的主目录在 C:\Users\myself
  • 我的网络主驱动器是公司网络上的 H:\ 并且一些工具认为我真正的家是 H:\

回答by Art Taylor

Have you tried command line ssh to the server, and then accepting the host key? That should store it, as it won't go through some Java/JNI/Windows contortions.

您是否尝试过命令行 ssh 到服务器,然后接受主机密钥?那应该存储它,因为它不会通过一些 Java/JNI/Windows 扭曲。

回答by Tommy

I'm not 100% sure what your problem is related to, but jetbrains has a page in their documentation about setting up ssh keys for git: using-git-integration.html

我不是 100% 确定您的问题与什么有关,但是 jetbrains 在他们的文档中有一个关于为 git 设置 ssh 密钥的页面: using-git-integration.html

I'm running idea on a mac and have my ssh keys in the standard unix ~/.ssh and I never get any questions about key stores. On windows you probably should put your ssh keys under C:\Documents and settings\username.ssh

我在 mac 上运行 idea 并且在标准 unix ~/.ssh 中有我的 ssh 密钥,我从来没有收到任何关于密钥存储的问题。在 Windows 上,您可能应该将 ssh 密钥放在 C:\Documents and settings\username.ssh 下

Also have a look at the version control tab in idea for more specific messages when troubleshooting vcs problems.

在对 vcs 问题进行故障排除时,还可以查看版本控制选项卡以获取更具体的消息。

回答by Mohsin Younas

Easy solution,
In the IDE
Tools-->Deployment-->options Scroll down, SFTP Advanced Options (IDE level settings)

简单的解决方法,
在IDE
Tools-->Deployment-->options 向下滚动,SFTP Advanced Options(IDE级别设置)

Changeadd new host key to known_known hosts to always

将向 known_known 主机添加新主机密钥更改始终

Change deployment settings

更改部署设置

回答by Jimy Ten

Open Terminaland run below given command SSHkey issue will be resolved.

打开终端并在给定的命令下运行SSH密钥问题将得到解决。

git config --global http.sslVerify false