git with IntelliJ IDEA: Could not read from remote repository
Asked Answered
C

35

279

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?

Columbian answered 19/12, 2014 at 13:18 Comment(8)
Did you manually add an SSH key to your git repository?Inexpiable
@Inexpiable yes, we're using GitLab, and I've posted it there into my profile.Columbian
IntelliJ is unhappy with your public/private key pair. How did you generate it?Rillet
@Rillet I tried both puttygen and Git GUI, as it was my first thought too. Are you sure it's about my key pair? The exception seems to be about the known hosts: code.google.com/p/connectbot/source/browse/src/com/trilead/ssh2/…Columbian
Not sure about the downvote - there seems to be a problem with hashed/unhashed entries in known_hosts. I'm going to dig into it a little further and answer the question.Columbian
On top of the other answers: If the .ssh directory and keyfile permissions are too weak git refuses the connection.Effectuate
Similar issue, but none of the current solutions worked. I installed 2018 EAP which has fixed an issue reported on Dec 2017. It finally worked!Bagdad
see also intellij-support.jetbrains.com/hc/en-us/community/posts/…Bagdad
C
24

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.

Columbian answered 3/2, 2015 at 8:21 Comment(0)
A
738

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.

Alleviator answered 6/7, 2015 at 5:42 Comment(20)
I know that it's possible to change the SSH implementation, I even explicitly wrote that I'm using the built-in executable (what I haven't wrote: native doesn't work for me on Windows) But you post doesn't answer my question what the problem with the built-in executable could be.Columbian
You may need to set up SSH for Git on your local machine. See confluence.atlassian.com/bitbucket/…Grantland
@Jimbo Just my assumption, but this is how I understand it: Built in uses another "User" in your repository, previously that "User" was allowed to push files and changes. That "User" was resetted in an Update and is no longer able to. Native uses the Account youre signed in on your machine.Legere
I had a similar problem but the error message in the Version Control tab was "Key exchange was not finished, connection is closed" - using the above answer fixed itBrandy
It's odd, but I could not push when the VPM was switched off! When I turned on, I could push changes into git repository.Jewelry
Strange. i had 3 separate computers all start doing this to me after working for 2+ years. this fixed it. WTFCrunode
@NicholasDiPiazza This is related to Github removing cryptographic standards github.com/blog/2507-weak-cryptographic-standards-removed . Also other software that use "built-in" libraries (e.g. TeamCity) are affected by this change. Your native git client is probably up-2-date, that's why this step fixes it.Despairing
ahhhh yes that explains it. i knew there'd be some reason. thanks for taking the time to do the legwork and come up with why!Crunode
This answer should be accepted. Fixed the problem for me when it suddenly appeared after working fine for 3+ years.Flatt
This answere did not fix the problem for me. And I HAVE the newest versions of all... switched to native... event my IDE is on 2017.3.6. Switching from ssh to https in git remotes like @Szymon Stepniak pointed out in his post, helped me like a charm. Thx to allGeothermal
this worked for me, I have pycharm installed on Ubuntu 16.04Pilferage
Switching from Native (what mine was on) to Built-In and back to Native worked for me. Curious.Postpositive
Just noticed that was a competing answer here. https://mcmap.net/q/107937/-git-with-intellij-idea-could-not-read-from-remote-repositoryPostpositive
I can push with the git GUI, but not with Webstorm on win7. Changing the ssh to native did not make a difference. As far as I remember it went broken when I added a passphrase to the key. But that was years ago...Middelburg
UPDATE Note that since version 2019.1 "SSH executable selector has been removed from the Git Settings". Read more here.Blither
Now this option is absent in Android Studio. What to do??Brunel
I'm facing the same issues without any solution. YET heheDraughtboard
Guys, I found a solution. For my scenario at least (Windows 10 + Android Studio + Git bash): 1. Open your ssh_config file inside of your git bash folder. (In my case: "C:\Users\odravison\AppData\Local\Programs\Git\etc\ssh\ssh_config"); 2. Inside of it, apend Host <my.git-company-repository.com> IdentityFile <~/.ssh/my_custom_key?name>; 3. Save it and that's it; -- you must replace "<...>" for your own value (without <> characteres)Draughtboard
To answer an old comment from @Flatt about why this answer isn't accepted: because it's not the correct solution for this problem. Having the wrong executable configured doesn't cause a java.io.IOException: Padding in RSA public key! error message. But obviously my issue was rather rare, which is why it's good to have this answer at the top anyways.Columbian
Thanks for clarifying @stuXnet, that reasoning makes sense. Also, what a blast from the past!Flatt
D
69

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.

Dreher answered 22/12, 2015 at 16:51 Comment(3)
Works fine in Android Studio as well. This issue was making me mad, thanks @Dreher jan!Ceremony
Toggling SSH executable worked for me. I was already on Native as well.Postpositive
For everyone considering going back to built-in: consider updating your native SSH first. The native executable is used throughout the OS and will behave consistently inside and outside your IDE.Dishman
D
57

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/

Drummond answered 28/2, 2018 at 23:39 Comment(7)
This is the solution that worked for me on a MacBook Pro, PHPStorm 2017.3.4) (January 30, 2018 before the noted 1/31 necessary build date).Lidstone
This solution worked, usually, the issue is many users try to use SSH key to define remote, but it gives you an error. Switching from SSH to HTTPS is the solution most of the times.Marsupial
using the link based on https slove my issue on PhpStorme version 2018.1.5Farrago
This solution worked for me on MacBook Pro , Intellij IDEA.Sachiko
Also works with GitLab to change the URL to https link.Barbusse
Worked for me too.Szczecin
Well, changing the path to git to higher version 2.17.1 can fix the ssh issue, provided private-public key were generated earlier.Biarritz
O
26

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

enter image description here

Check 'Use credential helper'.

Ogata answered 28/10, 2020 at 9:54 Comment(2)
Uncheck it right?? or check?Etana
I recall: it should be "checked".Ogata
C
24

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.

Columbian answered 3/2, 2015 at 8:21 Comment(0)
B
15
  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.
Buttaro answered 16/5, 2018 at 16:0 Comment(3)
Where's the connection between SSH & replacing the URLs with the HTTPS protocol?Swipple
i just wanna know, where on earth did anyone mention github here?Upsilon
This worked for me, It asked me for my bitbucket credentials, then its good to go.Epicritic
R
13

in pyCharm,

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

Here change SSH executable from Built-in into Native

then press apply and close

Ricardoricca answered 28/3, 2018 at 12:44 Comment(0)
E
11

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

Epithet answered 17/9, 2017 at 19:18 Comment(7)
Not a good option on my case... Now I can't re-add it again, getting the message "Invalid remote [...] Remote URL test failed: Could not read from remote repository. " Obs: I can connect to github through git cli.Bagdad
Same issue as @BagdadHowlend
@uri none of the solutions worked for me. I installed 2018 EAP which has fixed an issue reported on Dec 2017. It finally worked! see also the post Update-ssh-key-to-use-new-passphraseBagdad
I added comments to the question, but they got hidden. So I added an answer too.Bagdad
For unknown me reason it works for PHPStorm 2017.4. Thanks!Slope
if you got "Invalid remote [...] Remote URL test failed: Could not read from remote repository. " it's because you set the URL like : "git@...." but you should put you url like this: github.com/..../.......gitRetroactive
Using WebStorm This also helped me. had HTTP configured, I removed and added again & it worked.Biota
G
5

what @yabin ya says is a cool solution, just remind you that: if u still get the same problem,go to Settings-Version Control-GitHub and uncheck the Clone git repositories using ssh.

Gutow answered 19/9, 2016 at 3:26 Comment(0)
P
5

You need to Generate a new SSH key and add it to your ssh-agent. For That you should follow this link.

After you create the public key and add it to your github account, you should use Built-in (not Native) option under Setting-> Version Control -> Git -> SSH executable in your Intellij Idea.

Plastic answered 23/1, 2017 at 7:50 Comment(2)
For me switching to Native solved the problem, on MacStemson
I struggled with this problem for about a week or so(luckily, I could use git command line in the meantime)..How I finally solved it was regenerating my SSH Keys, but also I had to restart my computer and use the command line ssh-add.Ess
T
3

We've recently updated from IntelliJ 12 to IntelliJ 14 Ultimate and we've encountered this problem too. Our solution was to disable the proxy in the settings. We also stopped remembering the passwords once, but might not sure if that helps. Proxy settings are under File-Settings-Apearance & Behavior-System settings-HTTP Proxy.

Thinia answered 28/5, 2015 at 13:21 Comment(2)
That's interesting! So you had the same stacktrace?Columbian
We had the same stacktrace (I've changed the answer a bit btw)Thinia
E
3

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

Entirely answered 3/3, 2018 at 16:8 Comment(0)
C
3

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

Cockatrice answered 16/4, 2019 at 13:38 Comment(0)
G
2

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

Gilberte answered 8/2, 2018 at 9:28 Comment(0)
A
2

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

Applecart answered 13/6, 2018 at 10:12 Comment(0)
A
2

The following checkbox helped me :

enter image description here

Africander answered 31/8, 2023 at 10:43 Comment(0)
P
1

Not a solution / workaround but perhaps an answer to the question 'what could be the problem':

Gitlab and the 'jetbrains built in ssh library' do not work well together. The library wants to use SHA1 based key exchange algorithm where gitlab (default) only allows SHA2 based key exchange algorithm's.

This was reported for at least TeamCity (https://youtrack.jetbrains.com/issue/TW-47704).

The fact that it also might be the cause for your pull/push problem in IntelliJ, and also my push-problem in PhpStorm is based on the ASSUMPTION jetbrains use the same 'built in library' for all their software.

Psychoanalysis answered 20/2, 2017 at 14:9 Comment(0)
E
0

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.

Ethical answered 19/12, 2014 at 13:19 Comment(1)
You got java.io.IOException: Padding in RSA public key! in the log when there are no sufficient permissions? That's interesting and could indicate a bug in IntelliJ's SSH handling.Columbian
K
0

I had this problem with a fork from some online course. I cloned my fork and ran into a permissions error. I couldn't understand why it was insisting I was my user from my other company. But as the previous commenter mentioned I had the Clone git repositories using ssh setting checked and I had forgotten to add an ssh key to my new account. So I did and then still couldn't push because I got THIS error. The way I solved it was to push using the Github Desktop client.

Takeaways:

  1. When you open a new GitHub account make sure to add an ssh key to it
  2. Use different ssh keys for different accounts
  3. In general I run into some GitHub issue on IntelliJ at least once or twice for every project. Make sure you have a copy of GitHub desktop and load your projects into it. It can and will help you with lots of problems you may run into with Intellij - not just this one. It's actually a really nice GUI client and free!
  4. It probably makes sense to do what @yabin suggests and use the native client on a Mac
Karie answered 22/12, 2016 at 1:16 Comment(0)
C
0

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

Cherriecherrita answered 29/5, 2017 at 14:39 Comment(0)
W
0

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.

Wolsky answered 28/2, 2018 at 22:20 Comment(0)
B
0

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

Bagdad answered 1/3, 2018 at 0:3 Comment(1)
Thanks for the Link. For others TL;DR, the key comment for me was Nate: "A solution that worked for me: under Settings > Appearance & Behavior > System Settings > Passwords..." ...Switch to Do not save, forget passwords after restart, Do the Pull, then switch it back.Presidium
M
0

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!

Moron answered 9/4, 2018 at 9:4 Comment(0)
E
0

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

Elmira answered 2/5, 2018 at 9:38 Comment(0)
P
0

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

[email protected]:USERNAME/REPOSITORY.git
Pettus answered 6/9, 2018 at 11:45 Comment(0)
G
0

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

Ginnifer answered 12/9, 2018 at 2:52 Comment(0)
B
0

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.

Bunns answered 1/10, 2018 at 10:38 Comment(0)
G
0

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 !

Greggrega answered 3/12, 2018 at 16:52 Comment(0)
H
0

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@..."
Huddersfield answered 30/3, 2019 at 6:38 Comment(0)
B
0

I changed git path and it worked.

enter image description here

Biarritz answered 20/8, 2019 at 20:27 Comment(0)
E
0

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
Etana answered 15/7, 2022 at 14:10 Comment(0)
L
0

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

Lindalindahl answered 29/11, 2022 at 6:23 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewBroadcasting
H
-1

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.

Heaume answered 5/3, 2018 at 20:57 Comment(0)
C
-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.

Corny answered 29/9, 2018 at 20:19 Comment(0)
E
-1

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

Epicritic answered 24/6, 2019 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.