Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(git bash) push to bitbucket ignores SSH key

I followed a bunch of blog trails around the web to find out how everything should be set up and I have the following situation:

First of all, ssh -T [email protected] returns the following result

conq: logged in as myuser.
You can use git or hg to connect to Bitbucket. Shell access is disabled.

That means I have the ssh key setup properly both local and in bitbucket, agreed?

I have a ~/.ssh/config with the following content:

Host bitbucket.org
 IdentityFile ~/.ssh/id_rsa

That key is there ofcourse.

However, when I try the command (taken from another tutorial) git push origin master, I will get a popup saying:

---------------------------
PuTTY Fatal Error
---------------------------
Disconnected: No supported authentication methods available (server sent: publickey)
---------------------------
OK   

like image 883
Benny Bottema Avatar asked Jun 25 '13 20:06

Benny Bottema


People also ask

How do I push to Bitbucket via SSH?

Use SSH keys to connect to Bitbucket repositoriesGo to Projects, click a project, and choose a repository from the list. Click Clone in the sidebar to see the clone URLs for the repository. Choose the clone URL you want to use. SSH is available if you have already added an SSH key to your account.


1 Answers

Judging by the error PuTTY Fatal Error, it looks like Git is trying to use PuTTY to authenticate with ssh. The thing is PuTTY is not aware of your setting in ~/.ssh, at all. The setting in ~/.ssh is only meaningful when using openssh, shipped with Git Bash. It looks as if you have set the GIT_SSH environment variable to plink.exe, which is a tool that's part PuTTY.

You have two choices: you can either use PuTTY and plink.exe for ssh operations, or you can use the openssh that is part of Git Bash.

If you use PuTTY, then you need to manage your ssh keys with pageant.exe, which is also part of PuTTY. It's a pretty nice tool. Run it, and in the task tray you should see an icon. Right-click on that icon to add your private key. The other step to use PuTTY is setting GIT_SSH but it looks like you've already done that. In this setup git push will use plink.exe, which being part of PuTTY, will correctly find the private keys stored by pageant.ext.

If you want to use the openssh that is part of Git Bash, then all you need to do is get rid of the GIT_SSH setting. One way to make sure the setting is really empty when using git push is if you run the command like this:

GIT_SSH= git push origin master
like image 192
janos Avatar answered Sep 28 '22 04:09

janos