2

I am using Git with Intellij in Windows 10 environment. For some reason my git credentials are messed up. When I try to fetch/clone, Intellij is not asking me the credentials to enter. It appears as if it is trying to use already stored git credentials. I am getting the following error when I try to fetch :

7:58:31.180: git -c core.quotepath=false fetch origin --progress --prune

java.io.IOException: Authentication failed: at org.jetbrains.git4idea.ssh.SSHMain.authenticate(SSHMain.java:298) at org.jetbrains.git4idea.ssh.SSHMain.start(SSHMain.java:172) at org.jetbrains.git4idea.ssh.SSHMain.main(SSHMain.java:137) Caused by: java.io.IOException: Publickey authentication failed. at com.trilead.ssh2.auth.AuthenticationManager.authenticatePublicKey(AuthenticationManager.java:262) at com.trilead.ssh2.Connection.authenticateWithPublicKey(Connection.java:443) at org.jetbrains.git4idea.ssh.SSHMain.tryPublicKey(SSHMain.java:352) at org.jetbrains.git4idea.ssh.SSHMain.authenticate(SSHMain.java:231) ... 2 more Caused by: java.io.IOException: Invalid PEM structure, '-----BEGIN...' missing at com.trilead.ssh2.crypto.PEMDecoder.parsePEM(PEMDecoder.java:138) at com.trilead.ssh2.crypto.PEMDecoder.decode(PEMDecoder.java:313) at com.trilead.ssh2.auth.AuthenticationManager.authenticatePublicKey(AuthenticationManager.java:171) ... 5 more fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

So, I googled and found various approaches and tried all of them only to find none is working for me.

I tried in the following ways:

1)Removing the credentials stored in Windows Credentials Manager

2)Change remote repository credentials (authentication) on Intellij IDEA 14

3)Git credential helper - update password

and so on.. Any other thoughts to fix the issue so that the Intellij would ask me the credentials before I fetch/clone my repo?

Ashok.N
  • 1,327
  • 9
  • 29
  • 64

2 Answers2

2

TL;DR Update to the latest version (2018.3 or above), it uses Native SSH by default and if everything works in the terminal, it should work in the IDE.

A bit more detailed answer below:

Git credential helpers work for HTTP-base connections. Judging by the error, you are using SSH, so no credential helper is involved so any manipulations around it will not help. The error message also belongs to the IntelliJ Built-in SSH client, and the reason is either wrong ssh-key in use or unsupported key format - and builtin client is known to not support new OpenSSH key format - see https://youtrack.jetbrains.com/issue/IDEA-151116

The solution to this is to configure IDE to use Native SSH, which is, in fact, telling git to use system default SSH client, or the one bundled with GitForWindows in case it is used. Native SSH is supposed to support the key format in use.

Prior to 2018.3, IntelliJ was not able to handle interactive prompts for passphrase or host verification, so ssh-agent had to be used. Stating from 2018.3, IntelliJ can handle those prompts and Native SSH is the default. So updating should solve the issue should it be the key format, or some specific .ssh config not supported by the builtin SSH client.

Dmitrii Smirnov
  • 7,073
  • 1
  • 19
  • 29
  • I was running into some other issues when I configured Native SSH, but downgrading git version to 2.17.0 has solved the problem. – Ashok.N Feb 20 '19 at 14:14
1

I was running into some other issues when I configured Native SSH, but downgrading git version to 2.17.0 from 2.20.1 has solved the problem

Ashok.N
  • 1,327
  • 9
  • 29
  • 64