SSH KEY INVALID
Asked by Cornelius:

Hi, all. I am new to bitbucket, and I am trying to connect UiPath (An automation tool) to bitbucket. I generated a ssh key on my pc using ssh-keygen and it got saved. When I open the key in notepad and paste in Add SSH key under Personal settings, it says the SSH key is invalid. Please advise if I am doing something wrong?

Best Regards


Answers:
author: Patrik S
body: Hello [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) and welcome to the Community!

It might have been the case that the command you used to generate the key used an encryption algorithm that is not supported by Bitbucket Cloud.

I would suggest trying to recreate the key following the instructions outlined in the following documentation, according to your platform :

* [Setup personal SSH keys on Windows](https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-windows/)
* [Setup personal SSH keys on MacOS](https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-macos/)
* [Setup personal SSH keys on Linux](https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-linux/)

It's important to note that the key you need to add to Bitbucket is the public key (the extension of the file will be.pub)

Hope that helps! Let us know in case you have any questions or run into any issues following the instructions in the above articles.

Thank you, [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) !

Patrik S

comments: author: Cornelius
body: Hi Patrik, thank you for your response. I've installed GIT and when running through GIT Bash, I am not able to start the SSH service. Do you have any advice re that?

![bitbucket.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291063i645C98D6BCAFFD72/image-size/large?v=v2&px=999 "bitbucket.PNG")


author: Theodora Boudale
body: Hi Cornelius,

Based on the output, it looks like there may be other ssh-agent processes running on this computer.

You can run the following command to double-check if there is another ssh-agent process running:

```
ps -a | grep ssh-agent
```

If there is, you don't need to start the ssh-agent again.

Kind regards,  
Theodora


author: Cornelius
body: ![SSH.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/291707i94377A58028FD5E9/image-size/large?v=v2&px=999 "SSH.PNG")

*** ** * ** ***

Hi Theodora, thank you for your prompt reply. I ran this and it took me to the next line, so I am not sure if the agent is running ?Then after I tried to start the agent as described on Set up SSH key for Windows. I get the following error. Would you please be able to advise?


author: Patrik S
body: Hello [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) ,

It seems like there's some issue with the installation of SSH. I would suggest uninstalling git for windows from your machine, and trying downloading and installing it again from <https://git-scm.com/download/win> .

Once the new installation is completed, you can try starting the SSH agent again. If the issue persists, could you try the same in a different machine and let us know if you get the same error?


author: Cornelius
body: Hi Patrik, I tried reinstalling, and it had the same issue. However, on a different machine I was able to, do you know of why it is not generating one on the desired machine?

I'll appreciate any advice.

Best Regards

Corenelius

![SNIP.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/292847i375648FC0E673AF7/image-size/large?v=v2&px=999 "SNIP.PNG")


author: Patrik S
body: Hello [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) ,

As this is particular to one machine only, it seems to be an issue with either the OS or the installation of SSH.

I would suggest trying the following command to compare the SSH version in each of the machines and check if the version are different :

```
ssh -V
```

Also, the ssh-agent is a tool used to facilitate the authentication when your ssh key contains a password, so you don't have to type the password every time. However, the ssh-agent is not required to connect to Bitbucket.

In this case, as an alternative to the ssh-agent, you could try creating a file called **config** in the directory **\~/.ssh/** with the following content :

     Host bitbucket.org     HostName bitbucket.org     User git     IdentityFile ~/.ssh/<name of your private key>     IdentitiesOnly yes

where in **IdentityFile** line you should provide the path to the private key, of which the corresponding public key you have already added to your Bitbucket account.

This config file will instruct SSH to use that key for any SSH connection to bitbucket.org domain. You can then use the command below to test cloning a repository you have access to :

```
GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone git@bitbucket.org:<workspace>/<repository>.git
```

Thank you, [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) !  
Patrik S


author: Cornelius
body: Hi Patrik, the versions were same. I managed to generate an SSH key through installing source tree and added it under Personal Key in Bitbucket. After I tried to push it to the repo by cloning the ssh url after git clone but I am getting an error saying failing to connect to bitbucket.org :(![bit.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/293347iF963F92D4C1EDA2C/image-size/large?v=v2&px=999 "bit.PNG")


author: Patrik S
body: Hello [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) ,

From the screenshot you have shared, it seems you are using a different tool to interact with Bitbucket, which seems to be UIPath. Unfortunately, I have limited knowledge of the UIPath configuration.

Did you have a chance to test creating the config file, and using the clone command with verbose logs I shared in my previous comment? That command needs to be executed inside the git bash terminal.

Thank you, [@Cornelius](/t5/user/viewprofilepage/user-id/5349926) !

Patrik S


Tags: bitbucket-cloud

cloud