How to store SSH host key in IntelliJ IDEA

2019-02-03 01:28发布

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.

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?

Using:

IntelliJ IDEA 10.5.1 with JDK 1.6.0_22 on Windows XP

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

"git.exe" as the git executable in IDEA

"IDEA ssh" as the SSH Executable in IDEA

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

7条回答
我想做一个坏孩纸
2楼-- · 2019-02-03 01:59

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 As dialog 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.

查看更多
爷的心禁止访问
3楼-- · 2019-02-03 02:03

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

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

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_hosts file updated.

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".

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.

  • 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:\
查看更多
唯我独甜
4楼-- · 2019-02-03 02:04

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 until I changed the SSH executable.

查看更多
We Are One
5楼-- · 2019-02-03 02:07

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

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.

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

This is a confirmed bug in IDEA; it should search:

  • %HOME%
  • %HOMEDRIVE%
  • %HOMEPATH%
  • %USERPROFILE%

Check also this issue.

查看更多
▲ chillily
6楼-- · 2019-02-03 02:09

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

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

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

查看更多
仙女界的扛把子
7楼-- · 2019-02-03 02:09

Open Terminal and run below given command SSH key issue will be resolved.

git config --global http.sslVerify false
查看更多
登录 后发表回答