Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA - git ssh - Permission denied (publickey)

I am not able to clone a repository from Intellij IDEA and fails with the below error, shown in the image.

However, I am able to clone the repository from command prompt successfully, shown in the below image.

Note that I have added the public key file to the Bitbucket successfully. Also, the below image shows the contents of the 'config' file as well.

enter image description here

As suggested in the comments, I have run the which git command and it points to the location /usr/local/bin/git as shown in the below image:

enter image description here

Also, IntelliJ's settings for 'Version Control' > Git also points to the same location i.e., /usr/local/bin/git as shown in the below image:

enter image description here

I have also provided the Intellij console tab error details in the below image:

enter image description here

like image 583
developer Avatar asked Oct 13 '25 10:10

developer


2 Answers

I had exactly the same problem recently using SSH as authentication method. The solution for me was to create a config file inside ~/.ssh (or modify it, if you already have one).

Inside this config file add:

Host github.com
  User git
  IdentityFile ~/.ssh/name_of_your_private_key

Then chmod 600 to the config file.

Of course you can replace Host and User with values according to any particular case.

Hope this helps ;)

like image 50
z_overload Avatar answered Oct 15 '25 08:10

z_overload


Open the Console tab of the Version control window in order to see what command is launched, and its full error message.

Regarding SSH URL, relaunch IntelliJ IDEA after exporting:

export GIT_SSH_COMMAND='ssh -Tv'

You will see in that console tab much more details regarding the clone attempt and its errors.

like image 35
VonC Avatar answered Oct 15 '25 08:10

VonC