git with IntelliJ IDEA: Could not read from remote repository

Since a few weeks, I'm not able to pull or push from or to the remote repository. I thought it happend when upgrading to IntelliJ IDEA 14, but I can reproduce the problem with IDEA 13.1.5 as well.

The tooltip says "Fetch failed fatal: Could not read from remote repository."

and the exception in the Version Control tab reads

14:02:37.737: cd C:devproject
14:02:37.737: git -c core.quotepath=false fetch origin --progress --prune
java.io.IOException: Padding in RSA public key!
    at com.trilead.ssh2.signature.RSASHA1Verify.decodeSSHRSAPublicKey(RSASHA1Verify.java:37)
    at com.trilead.ssh2.KnownHosts.addHostkey(KnownHosts.java:98)
    at com.trilead.ssh2.KnownHosts.initialize(KnownHosts.java:414)
    at com.trilead.ssh2.KnownHosts.initialize(KnownHosts.java:440)
    at com.trilead.ssh2.KnownHosts.addHostkeys(KnownHosts.java:137)
    at org.jetbrains.git4idea.ssh.SSHMain.configureKnownHosts(SSHMain.java:462)
    at org.jetbrains.git4idea.ssh.SSHMain.start(SSHMain.java:155)
    at org.jetbrains.git4idea.ssh.SSHMain.main(SSHMain.java:137)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Using the built-in terminal of IntelliJ, executing git -c core.quotepath=false fetch origin --progress --prune , it works just as it should.

According to the stacktrace, there seems to be a problem with my KnownHosts , so I deleted our git server from ~/.ssh/known_hosts , hoping IntelliJ would insert it again. But the problem still appears when updating via the UI, and there is no new entry written in known_hosts ; thinking about some caching of the file, I restarted IntelliJ, without success.

When doing another git fetch from the terminal, now I'm getting asked if I want to permanently add the server. After that, it has been written to known_hosts again, but IntelliJ still won't let me update my project.

I haven't found anything about this behavior online, so I guess it's not a known bug with the new IntelliJ version. Nevertheless, I updated to 14.0.2, but the problem still exists.

IntelliJ is configured to use the built-in SSH executable.

Does anybody have a clue what could be the problem here?


settings-->Version Control-->Git ,and then, In the SSH executable dropdown, choose Native

版本控制:Git:SSH可执行文件:用于当前项目

If this doesn't help, ensure that your native ssh and git clients are a sufficiently recent version.


Go to Preferences > Version Control > Git. Make sure SSH executable is set to “Native.” (If it's already so, switch it to “Built-in,” apply it, and then again switch back to “Native.”).

If this doesn't solve your issue, I would suggest to download a Git client such as GitHub client (free desktop app) and try to sync your project through the app. Then go back to IntelliJ and check if it works.


I started getting Could not read from remote repository error recently when working with my github repository. My specs:

  • IntelliJ IDEA 2017.3.4 (Ultimate Edition)
  • Settings -> Version Control -> Git -> SSH executable -> Built-In
  • Fedora Linux
  • 在这里输入图像描述

    Of course those problems occurred only when trying to push/pull/fetch etc. from IDE - executing same commands from command line worked like a charm.

    Solution that worked for me

    I didn't want to switch from Built-In SSH executable to Native , mostly because my native SSH client asks me for the password anytime I try to sync with remote repository.

    I solved this problem by switching from SSH remote URL to HTTPS URL. According to this GitHub help page - it is recommended to use HTTPS URL instead of SSH one.

    Changing remote URL from SSH to HTTPS

    In IntelliJ IDEA go to VCS -> Git -> Remotes..., select row containing "origin" and click on edit button. If you host your repository on GitHub, replace your SSH URL from:

    git@github.com:USERNAME/REPOSITORY.git
    

    to:

    https://github.com/USERNAME/REPOSITORY.git
    

    You can also get your HTTPS URL from your GitHub repository home page - click on "Clone or download" button and click on "Use HTTPS" link to display your repository's HTTPS URL:

    在这里输入图像描述

    UPDATE 2018-03-13

    JetBrains just released IntelliJ IDEA 2017.3.5 that includes fix for SSH access to GitHub - https://blog.jetbrains.com/idea/2018/03/intellij-idea-2017-3-5-fix-for-ssh-access-to-github/

    链接地址: http://www.djcxy.com/p/27078.html

    上一篇: Git问题与Visual Studio 2015

    下一篇: git与IntelliJ IDEA:无法从远程存储库读取