stuXnet
stuXnet

Reputation: 4349

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:\dev\project
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?

Upvotes: 280

Views: 250741

Answers (30)

Buddy Hu
Buddy Hu

Reputation: 18

In macOS SystemSettings > Security > Local Network make sure that searches are enabled.

Upvotes: 0

Ahmed Ashour
Ahmed Ashour

Reputation: 5549

For me the solution was: Settings ˃ Version Control ˃ Git ˃ Use Credential helper

enter image description here

Check 'Use credential helper'.

Upvotes: 33

Kunal Khaire
Kunal Khaire

Reputation: 327

The following checkbox helped me :

enter image description here

Upvotes: 2

Sidharth Yatish
Sidharth Yatish

Reputation: 31

Update for version 2022.2.4 From so many answers above, I updated my ssh config but still Intellij could not do git actions The only missing step was chmod 600 ~/.ssh/config and chown $USER ~/.ssh/config. After this, I restarted Intellij and it was working

Upvotes: 0

Gk Mohammad Emon
Gk Mohammad Emon

Reputation: 6938

I'm facing the same issue with the latest Android Studio version on macOS (Version Chipmunk|2021.2.1). So I'm not using Intellij (Android studio) for the cloning project. I do it by the following command -

git clone https://YOUR_GIT_DEVELOPER_KEY_FROM_CONSOLE@YOUR_GIT_URL 

Suppose this is your repo, so it will be like that

git clone https://[email protected]/Gkemon/Android-XML-to-PDF-Generator.git

Upvotes: 0

Smart Coder
Smart Coder

Reputation: 1738

I changed git path and it worked.

enter image description here

Upvotes: 0

Marlon
Marlon

Reputation: 1897

When adding the remote URL change it from this

https://[email protected]/usernameowner/project-name.git

to this

https://bitbucket.org/usernameowner/project-name.git

Upvotes: -1

Volodymyr
Volodymyr

Reputation: 6569

I've resolved this by adding my SSH private key to the ssh-agent in the command:

$ ssh-add -K ~/.ssh/id_rsa

And setting Settings --> Version Control --> Git, and then, in the SSH executable dropdown, choose Native

Upvotes: 4

Alireza Alallah
Alireza Alallah

Reputation: 2534

I tried Native option but does not work for me, finally regenerate ssh key in old way and add -m option in ssh-keygen command. also IDEA works with build-in option as fine.

ssh-keygen -m PEM -t rsa -b 4096 -C "email@..."

Upvotes: 0

yabin ya
yabin ya

Reputation: 7291

Settings --> Version Control --> Git, and then, in the SSH executable dropdown, choose Native

Version Control: Git: SSH executable: For current project

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

Upvotes: 738

NullPointer
NullPointer

Reputation: 261

I had the same problem. Was using bitbucket and had trouble in pulling/updating the repository on Intellij. Tried changing to native and back to built in, but it was not working. Then realized that I had generated the ssh key with a passphrase.

I regenerated the key without the passphrase and then added it to the bitbucket. It worked !

Upvotes: 0

user3231514
user3231514

Reputation: 1

I tried all solutions above (Native, changing url of VCS repository, updating Git, updating IDEA, invalidating Caches), but nothing helped me. Finally I found solution that works for me.

SOLUTION: I closed Idea and replaced content of file ~\.IntelliJIdea20xx.x\config\options\git.xml with this:

<application>
  <component name="Git.Application.Settings">
    <option name="SSH_EXECUTABLE" value="IDEA_SSH" />
  </component>
</application>

Then I started IDEA, try to checkout SSH GIT repository and it works and existing projects works as well. Interesting fact is that when I switch to NATIVE in Idea Settings, repository not working.

Upvotes: 0

Phoelix Sky
Phoelix Sky

Reputation: 1

Nothing helped me. Then I saw that the name of the project on the computer is different from the name on the git repository.

So I solved the problem.

Upvotes: -1

Gaurav
Gaurav

Reputation: 559

Adding this answer since none of the answers worked for me.

I had certificates issue - so following command did the trick.

git config --global http.sslVerify false

taken from https://confluence.atlassian.com/fishkb/unable-to-clone-git-repository-due-to-self-signed-certificate-376838977.html

Upvotes: 0

Sugoi Reed
Sugoi Reed

Reputation: 497

I Solved the issue simply by ensuring that I had the correct git SSH url without any trailing spaces:

[email protected]:USERNAME/REPOSITORY.git

Upvotes: 0

connexo
connexo

Reputation: 56754

This fixed it for me (I am using SSH, not HTTPS, and the native git, not the built-in) on MacOS High Sierra (10.13.5)/IntelliJ IDEA 2018.4:

File -> Invalidate Caches and Restart

Upvotes: 3

Sarvesh Athawale
Sarvesh Athawale

Reputation: 281

  1. Go to Settings->Git->Select Native in SSH executable dropdown. (If it is not selected)
  2. Copy HTTPS link from your Github repository.
  3. Go to VCS->Git->Remotes..
  4. Edit the origin and Paste HTTPS link in the URL field.
  5. Press Ctrl+Shift+k and push the project to repository. It works.

Upvotes: 16

binithb
binithb

Reputation: 2000

Check Idea proxy settings if you are trying to connect to cloud services like github or bitbucket. This can be done by looking for plugins to install or by checking for software updates in the help menu. If the internet/proxy settings are not correct add valid entries or set it to auto

Upvotes: 0

Mohideen bin Mohammed
Mohideen bin Mohammed

Reputation: 20137

in pyCharm,

file|
    v-->settings|
                v-->Version Control|
                                   v-->Git

Here change SSH executable from Built-in into Native

then press apply and close

Upvotes: 14

Viral Nakrani
Viral Nakrani

Reputation: 11

The problem is solved in my pc.
settings-->Version Control-->Git ,and then, In the SSH executable drop-down, select built-in option.

and install git older version something like 2.14.2.
Its works good!

Upvotes: 0

Szymon Stepniak
Szymon Stepniak

Reputation: 42184

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

  • IntelliJ IDEA 2017.3.4 (Ultimate Edition)
  • Settings -> Version Control -> Git -> SSH executable -> Built-In
  • Fedora Linux

enter image description here

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:

[email protected]: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:

enter image description here

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/

Upvotes: 58

SilverK
SilverK

Reputation: 19

Ensure that you've changed the link to the git repository to the HTTPS option after you've selected "Native" in IntelliJ settings if SSH doesn't work.

Upvotes: -1

Jenya Kirmiza
Jenya Kirmiza

Reputation: 711

this helped me to fix current issue

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.

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa

source

Upvotes: 4

Ricardo
Ricardo

Reputation: 4308

I had this issue with WebStorm recently (February/2018) and none of the (then) previous solutions worked for me. After spending some hours on troubleshooting and researching, I installed the 2018 EAP version and now it works!


A new issue reported on December/2017 on IntelliJ Idea > VCS/Git subsystem which was fixed in build 181.2445 (or any latest build after 31/Jan/2018).

See also the post Update-ssh-key-to-use-new-passphrase

Upvotes: 0

Wilmer E. Henao
Wilmer E. Henao

Reputation: 4302

If all else fails just go to your terminal and type from your folder:

git push origin master

That's the way the Gods originally wanted it to be.

Upvotes: 0

stuXnet
stuXnet

Reputation: 4349

IntelliJ's built-in SSH client seems to hash its known_hosts, but the one I had had its host names in clear text.

When I deleted the file and let IntelliJ create a new one, with only my (hashed) GitLab server and nothing else, it worked.

It's also not possible to mix it - keep some unhashed entries together with hashed entries for IntelliJ. So, you have to configure your other SSH clients to use hashed hosts.

Upvotes: 25

Steve Borland
Steve Borland

Reputation: 380

I solved this issue by removing the password for the ssh key in PuTTY.

Upvotes: 3

Nikita Zamalyutdinov
Nikita Zamalyutdinov

Reputation: 169

I solved this issue by re-adding remote repository: VCS -> Git -> Remotes.

Upvotes: 12

Rahal Danthanarayana
Rahal Danthanarayana

Reputation: 748

Don't forget to contact your system administrator.

Because in my case I had every thing rightly configured(SSH also added) but I got the same error

repository access denied. fatal: Could not read from remote repository.

the reason was I only had read access to that repository. Therefore with out wasting your valuable time please check that as the first thing. Thank you.

Upvotes: 0

Patrick Dorn
Patrick Dorn

Reputation: 768

The only thing that helped in my case (switch SSH-executabe did not work) was to deactivate the git and git-flow plugin, restart intellij and reactivate those plugins again...

Upvotes: 0

Related Questions