Bamboo Upgrade SSH issue
Asked by junfang li:

I cannot start the old stash 3.1 and bamboo 5.6 on a server due to some security reasons. So I am upgrading them to the latest version on another server.

BitBucket starts fine without any issues.

But when I start the new bamboo, I got below error in the log file, and these errors wont end, it is like an infinite loop.
> 2017-09-13 03:31:08,086 INFO \[10-BAM::PlanExec:pool-17-thread-1\] \[DefaultErrorHandler\] Recording an error: Unable to detect changes : TBL-VM : com.atl  
> assian.bamboo.plugins.git.GitCommandException: command /usr/bin/git ls-remote ssh://f6d781cf-2e5f-4c20-bfba-735f0e700643@127.0.0.1:43470/xxx/xxx-website.git failed with code 128. Working directory was \[/opt/bamboo/atlassian-bamboo-6.1.0/temp\].,
>
> stderr: Authenticating remote session failed  
> stdout: Warning: Permanently added '\[127.0.0.1\]:43470' (RSA) to the list of known hosts.
>
> BAMBOO-SSH-PROXY: \[SSH proxy tried to connect to \[git@git.xxx.com/xxx.xxx.xxx:7999\]: and failed due to the following error: \[Authenticating remo  
> te session failed\]: No more authentication methods available\]  
> fatal: Could not read from remote repository.  
> Please make sure you have the correct access rights  
> and the repository exists.

I checked the new BiBucket, Access Keys are not set in all the projects.

But from the ssh error in the log I think it is using a shared credential in Bamboo? Does this error mean that the private key in Bamboo doesnt match with the public key(it is empty in the upgraded bitbucket) in BitBucket? How do I retrieve the private key from the old bamoo file system?


Answers:
author: Jeyanthan I
body: Generally, when you've changed your environment, such as upgrading, migrating physical servers or even URLs, it's best to recreate the [application link](https://confluence.atlassian.com/applinks/link-atlassian-applications-to-work-together#LinkAtlassianapplicationstoworktogether-delete) on both sides (as recommended in [Application Links Troubleshooting Guide](https://confluence.atlassian.com/kb/application-links-troubleshooting-guide-718668765.html)) . Try that first as many things are changed in the latest versions of Bamboo and Bitbucket.

If you still cannot get it working, run the same ssh command from a command prompt outside Bamboo and confirm if you are able to successfully authenticate via ssh as the same user and produce result.

Let me explain briefly how we authenticate when Bamboo works with Bitbucket repositories.

1. When configuring repository definition on Bamboo side (either in Plan or in Administration/Linked repositories) Bamboo will create SSH keypair and will store private key in the repository configuration and upload public key to Stash (it can be seen in the list of SSH keys of a user X who defined repository on Bamboo side).
2. When running a build Bamboo will present the private key thus making Stash recognise it as user X (no matter how plan was run).

Please, make sure the user saving repository configuration in Bamboo has permissions to the repository in Bitbucket.

comments: author: junfang li
body: it worked after update the [application link](https://confluence.atlassian.com/applinks/link-atlassian-applications-to-work-together#LinkAtlassianapplicationstoworktogether-delete) in bamboo and bitbucket.


Tags: ssh

upgrade