Permission denied(Public Key)for submodule in Bamboo 9.2.1
Asked by Bhagyalaxmi:

I am trying to checkout the submodules. I used **ADVANCED SETTINGS(Bamboo respositories)\>Use Submodules.** I ticked **SSH key applies to submodules.**

Even with these configurations, the bamboo plan fails.

I get the following error:

```
git@bitbucket01.com.stihlgroup.net: Permission denied (publickey).fatal: Could not read from remote repository.	Please make sure you have the correct access rightsand the repository exists. 
```


Answers:
author: Bhagyalaxmi
body: Hello [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410) ,

The solution you provided me earlier in the thread, does not work.

Bamboo agents runs as a window service and the local system account comes into picture here.

Requesting assistance.

Regards,

Bhagyalaxmi


author: Shashank Kumar
body: Hello Bhagyalaxmi,

Welcome to Atlassian Community

I am not sure which version of Bamboo you are using, but if you are using version before 8.1 you'll have to upload and configure ssh keys on each Bamboo agent, more details at <https://jira.atlassian.com/browse/BAM-11369>

You can also read <https://confluence.atlassian.com/bamkb/plans-with-git-submodule-fail-in-bamboo-server-dc-with-repository-not-found-or-authentication-failed-messages-1026524045.html> which explain few solution to fix the problem.

Regards,

Shashank Kumar

**\*\*please don't forget to Accept the answer if your query was answered\*\***

comments: author: Bhagyalaxmi
body: Hello Shashank Kumar,

Thank you for a reply.

I am using Bamboo version 9.2.

I tried the following the solutions proposed except the **"relative SSH URLs in your .gitmodules file".**I receive the same problem.

Regards,

Bhagyalaxmi


author: Bhagyalaxmi
body: I generated the key pair using ssh command so the bamboo agent has the key pair and bitbucket server has the public key.


author: Eduardo Alvarenga
body: Hello [@Bhagyalaxmi](/t5/user/viewprofilepage/user-id/5273765)

You will have to grant access to the same SSH public key presented on your base Linked Repository in Bamboo to any repositories linked as a submodule.

On your "main" Linked Repository options in Bamboo, expand the **Advanced Options** and locate the SSH public key listed on "**Public key generated for this repository**".

On your Bitbucket server, locate the repository listed as a submodule and add that SSH public key listed in Bamboo to **Repository** \>\> **Repository Settings** \>\> **Access keys**.

Kind regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**


author: Bhagyalaxmi
body: I made the repo a linked repository.

How to attach SSH key from the linked repository to the submodules individually?

As of now, my account at the bitbucket server has the public key from the ssh connection. In Bitbucket web interface, the keys are present in **MANAGE ACCOUNT\>\>SSH KEYS.**

I still get the same error.


author: Eduardo Alvarenga
body: Hello [@Bhagyalaxmi](/t5/user/viewprofilepage/user-id/5273765),

You must add the SSH public key to the Repository Properties in Bitbucket. You need Bitbucket Admin access to configure the repository keys.

* **Repository** \>\> **Repository Settings** \>\> **Access keys** .

Kind regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**


author: Bhagyalaxmi
body: Hello [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410) ,

Here, what is the purpose of creating a linked repository?

Regards,

Bhagyalaxmi


author: Eduardo Alvarenga
body: Hello [@Bhagyalaxmi](/t5/user/viewprofilepage/user-id/5273765),

You can still use Plan Repositories for that task. Linked repositories are the recommended practice as Plan repositories are planned to be deprecated.

Submodules will also work at the Plan level.

For more information please check this page:

* [Linking to Source Code Repositories](https://confluence.atlassian.com/bamboo/linking-to-source-code-repositories-671089223.html)

Best regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**