SSH KEY BITBUCKET

Hi,

I get "Invalid ssh key" when following the instructions on the tutorial for windows when I try to enter a new ssh key. Keys are generated running ssh-keygen.

Same thing happens when generating keys in our ubuntu server again using ssh-keygen.

The only way I was able to enter a valid key was by using the intructions given on the following blog:

http://blog.muhammada.li/setting-up-ssh-access-to-bitbucket-on-windows

which uses puttygen to generate the keys. Why is that ?

Is is necessary to convert keys to a different format ? Or, is it possible to enter puttygen s generated keys instead of generating them with ssh-keygen ?

Regards

José

7 answers

1 accepted

The problem was not winvi or notepad, actually you need to copy the key only up to the "==" part at the end. Thanks for your help.

Jose,

You don't say whether you are using GitBash but I'll assume you are. Without the command + the output your situation is hard to debug.

You might have a situation where your adminstrator is blocking SSH on port 22. You can try our toubleshooting guide to find out more:

https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues

Mary

I think I see your issue. Can you remove your name from the tail end when you copy it? Sometimes there are issues with non-ascii characters.

Hi Mary,

Thanks for your fast answer. I do not think it s our firewall blocking port 22, actually we are analyzing moving from Github to Bickbucket (Github does ork over ssh). Also it looks like the problem is with the key itself, I mean, the problem is that keys generated by ssh-keygen are not accepted by Bitbucket.

Yes, I am using GitBash in windows and openssh_5.9 in the case of our ubuntu server.

Please correct me if I am wrong:

In windows:

*I open GitBash and run ssh-keygen
*I open winvi and copy id_rsa.pub contents (GitBash does not let me select text using the mouse)
*I paste the contents of id_rsa.pub to the "Key" field on the SSH Keys entry in my account

Here s a sample key as generated with ssh-keygen

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAy8c18qkT/DVkLb3H2JZUbHXEdyTfMI/qSN6tV83upg8W7q7MmqtfMtMOjkCYJxzY8nCHlrT9CTzTebxgxRMMSvw6rXa7MAV3ZVn2DTjKPx0IkKiPJyjA7wT97JNSL1r7AxLT9TGq+WuLkB7WXWBnMnSv1OxxV0l34DSbIxDgo6CbaLrVlGR7argYw9Lcxkw7Z9bacWgSb8JYdgvZ5m66siRgBA2Q1IHT6f9cVlkgc0PONWLbtvCVCUjXZnx7RqW2F4VCcBFcoTUgh76iUdWSfojFk1Hdp8PCYbdbyoF+4T6nRCubPi85YFBi6zkSiJmdvGJrmEcUMkHmqq0luHCiKQ== José@JOSE-DV5

And here s a sample key as generated with puttygen

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEA2V0QPwQzbpz4tG5T5Qjo4GTgd/nChpq4xtu0jcI8jp0kXN2asPSDye7ceWcd6dypQIm3voyOgQ2ropaHRqVgjAKaQMvSXhMruUSHfjEEkCJz0H2Mj+P8Z/zg9/eP2YgPguW7W4m6pYivT0kZfkCiKkzc9oWyfIt7NVjgSaDrLJE= rsa-key-20130513

This last entry is accepted by Bitbucket, while the other is not. I can notice some differences, for example, ssh-keygen s generated key mentions my name and computer name at the end while puttygen s key ends with rsa-key and a number, but I do not have a clue on what these differences mean.

Please let me know if you need me to run any other command and I will copy it s output to you.

Regards

Jose

From your description, it sounds like this could also be a copy/paste error. If you've generated a key on Ubuntu and the website is telling you 'invalid key' that probably means that there are line breaks in the copy. It can depends on what method you used to copy the key.

Are you following our entire 101 from start to finish setting up both Git and Hg? There are some steps that are present in Git related pages and not Hg and vice versa. The guide is meant to be followed completely. For example, setting up SSH for Hg includes instructions using puttygen.

Lastly, that other blog was written a very long time ago before the 101 guide was completely rewritten from the ground up. Id' advise trying it and please let us know your specific issues here, in comments on it or directly in private to support@bitbucket.org. Our goal is to get you going quickly whichever method you choose.

Hi Mary,

Thanks for your fast answer. I do not think it s our firewall blocking port 22, actually we are analyzing moving from Github to Bickbucket (Github does ork over ssh). Also it looks like the problem is with the key itself, I mean, the problem is that keys generated by ssh-keygen are not accepted by Bitbucket.

Yes, I am using GitBash in windows and openssh_5.9 in the case of our ubuntu server.

Please correct me if I am wrong:

In windows:

*I open GitBash and run ssh-keygen
*I open winvi and copy id_rsa.pub contents (GitBash does not let me select text using the mouse)
*I paste the contents of id_rsa.pub to the "Key" field on the SSH Keys entry in my account

Here s a sample key as generated with ssh-keygen

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAy8c18qkT/DVkLb3H2JZUbHXEdyTfMI/qSN6tV83upg8W7q7MmqtfMtMOjkCYJxzY8nCHlrT9CTzTebxgxRMMSvw6rXa7MAV3ZVn2DTjKPx0IkKiPJyjA7wT97JNSL1r7AxLT9TGq+WuLkB7WXWBnMnSv1OxxV0l34DSbIxDgo6CbaLrVlGR7argYw9Lcxkw7Z9bacWgSb8JYdgvZ5m66siRgBA2Q1IHT6f9cVlkgc0PONWLbtvCVCUjXZnx7RqW2F4VCcBFcoTUgh76iUdWSfojFk1Hdp8PCYbdbyoF+4T6nRCubPi85YFBi6zkSiJmdvGJrmEcUMkHmqq0luHCiKQ== José@JOSE-DV5

And here s a sample key as generated with puttygen

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEA2V0QPwQzbpz4tG5T5Qjo4GTgd/nChpq4xtu0jcI8jp0kXN2asPSDye7ceWcd6dypQIm3voyOgQ2ropaHRqVgjAKaQMvSXhMruUSHfjEEkCJz0H2Mj+P8Z/zg9/eP2YgPguW7W4m6pYivT0kZfkCiKkzc9oWyfIt7NVjgSaDrLJE= rsa-key-20130513

This last entry is accepted by Bitbucket, while the other is not. I can notice some differences, for example, ssh-keygen s generated key mentions my name and computer name at the end while puttygen s key ends with rsa-key and a number, but I do not have a clue on what these differences mean.

Please let me know if you need me to run any other command and I will copy it s output to you.

Regards

Jose

Jose,

I just ran a test in GitBash I generated a key with ssh-keygen and pasted it into BB. The key was accepted.

The only difference was I used Notepad to open the key. Selected All, copied, and pasted into BB. Would you mind trying Notepad?

Mary

Yes, it looks like it was a broken key issue. What I did was to ftp the key to my windows PC and copied it from there. Thanks for your help.

I hate ssh key setup I need to keep using http although it keeps asking password.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

683 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot