Where do I stick ssh keys for submodules?
Asked by Andrew Arminio:

I'm running bamboo under my own user account. My home directory is C:/Users/me/. The bamboo home is C:/Users/me/bamboo-home/. Under my home directory I have .ssh/id-rsa and .ssh/id-rsa.pub.

When I run git submodule update --init from git bash all my submodule update properly.

My bamboo plan is configured to pull from bitbucket using ssh. I've told it to use C:/Users/me/.ssh/id-rsa as it's private key file, and provided it with the passphrase for that key. As indicated above, that ssh key and pasphrase work with all the submodules in my repository. The bamboo plan is configured to use submodules.

When I run my bamboo plan it clones the original repository fine, but fails while checking out submodules.

```
Permission denied (publickey).
```

If I make a copy of C:/Users/me/.ssh in C:/Users/me/bamboo-home/.ssh I recieve the same error.

What do I have to do to make bamboo use my original ssh ke/passphrase on submodules? If I need to set up a new ssh key without a passphrase I can do that, but what directory should I put it in that bamboo will pick it up and use it. Is there a configuration setting in bamboo so I can setup deploy-keys?

Edit: I've tried moving both base repository and one of the submodules to https instead of ssh. I configured the base repository to use my bitbucket login and password. The submodule is also under my bitbucket account. After doing this, bamboo pulls the base repository fine, but just sort of hangs when trying to fetch the submodule.

Edit2: I've created ssh keys with no passphrase and put them in C:/Users/me/bamboo-home/.ssh. I setup the bamboo plan to use this key, as well as setting them up with my bitbucket user. This has resulted in the same behavior as last time.


Answers:
author: Marcin Gardias
body: Hi,

The problem is, I believe, caused by Windows' mechanism called Virtual Store. This functionality is intended to prevent user from accidentally changing important files. Unfortunately, it also cause ssh to store its files into weird places.

2 things you can try:

1) copy your .ssh into sth like that:

C:\\Users\\me\\AppData\\Local\\VirtualStore\\Program Files (x86)\\Git\\.ssh

(above assumes 64 bit windows, on 32bit the path is simply 'Program Files')

2) use this script:

C:\\Program Files (x86)\\Git\\cmd\\git.cmd

as your Git executable in Bamboo. This script resolves the path problem so Git is no longer 'confused' by Virtual Store thingy.

I hope this helps.

comments: author: Andrew Arminio
body: I tried the second option first and everything is working fine now, though I still had the non-passcode keys in my user/.ssh leftover from a previous test. But that's something I can change around once we get bamboo runnig under a dedicated service account. Thanks!


author: Ha Le
body: Ran into the same problem,

1) Couldn't find Virtual store in \~/AppData/Local

2) Have tried this (Git 1.8.3), git.cmd is no longer there, it's replaced by git.exe (also a wrapper), and it does not work.

Marcin do you have another suggestion? Thanks!


author: Faik Uygur
body: On Windows you have to create HOME system environment variable pointing to the directory where .ssh folder is.

ex:

if .ssh folder is at C:/Users/Bamboo-Admin/.ssh than

HOME=C:/Users/Bamboo-Admin

<br />

<br />

comments: author: Thomas Langston
body: I did this. I used a user variable instead of a system variable since Bamboo is running under Administrator. I also had to create a new ssh key that didn't require a passphrase.


author: vprudnikov
body: I have the same issue on Ubuntu and Bamboo 5.7.1 build 5715. Tried to add separate source code checkout for the repositor linked as submodule (which was failed to init/checkout as a submodule) --- works great.


author: Craig Murray
body: Same problem here:

1. the virtual store folder described in solution 1 do no exist, if I create them, still doesn't work

2. git.cmd is gone, using cmd/git.exe version does not solve the problem.


Tags: git

ssh

submodule