1

I'm pulling my hair out trying to get Berkshelf to download a company cookbook from our private BitBucket (git) repository. This is on a Windows 8.1 host.

I found this question and have attempted what was described in the answer. I also played around with the instructions Atlassian advises about here and especially on their page about ssh for multiple identities.

  • I have generated a public key with puttygen and added it as a deployment key to Bitbucket repo.
  • I saved the private key in C:\Users\MyUser\.ssh\mykey.ppk.
  • I added C:\Users\MyUser\.ssh\config with the following contents:

    Host mycompany HostName bitbucket.org IdentityFile ~/.ssh/mykey.ppk

  • I try to include the cookbook in berksfile like this:

    cookbook 'mycookbook', git: "git@mycompany:myteam/mycookbook.git", protocol: :ssh

When I run $ berks install -d I get:

Fetching 'mycookbook' from git@mycompany:myteam/mycookbook.git (at master)
Enter passphrase for key '/c/Users/MyUser/.ssh/mykey.ppk':
Git error: command `git clone git@mycompany:myteam/mycookbook.git "C:/Users/MyUser/.berkshelf/.cache/git/6d5b957656d1bda26bf05aea558176c86db263f2" --bare --no
-hardlinks` failed. If this error persists, try removing the cache directory at 'C:/Users/MyUser/.berkshelf/.cache/git/6d5b957656d1bda26bf05aea558176c86db263f2'.Output from the command:

Cloning into bare repository 'C:/Users/MyUser/.berkshelf/.cache/git/6d5b957656d1bda26bf05aea558176c86db263f2'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Any idea why this is not working?

Do I have to replace 'git' in front of the @ with my user name?

Also - note that it asks me for the passphrase of the ppk, which I just confirm with `enter' as I left it blank. But shouldn't it just read it without prompting for it?

Community
  • 1
  • 1
phpPhil
  • 906
  • 1
  • 9
  • 28

1 Answers1

1

Here are a couple of suggestions:

  • Make sure that the environment variable HOME is set to C:\Users\MyUser when you are running the berks command.
  • Use a full path for the private key

    Host mycompany
    HostName bitbucket.org
    IdentityFile /C/User/MyUser/.ssh/mykey.ppk
    
  • try and use rsa keys instead of private putty keys (ppk)

    ssh-keygen -t rsa
    

(reference the private key in IdentityFile: the id_rsa one, add the public one to the BitBucket repo)

The OP phpphil confirms in the comments:

Turned out the last point fixed it - I used the puttygen user interface to export the key Conversions -> Export OpenSSH key as mykey.pub, then simply changed the config to IdentityFile ~/.ssh/mykey.pub.
It worked with the relative path as well.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Genius! Turned out the last point fixed it - I used the puttygen user interface to export the key `Conversions -> Export OpenSSH key` as `mykey.pub`, then simply changed the config to `IdentityFile ~/.ssh/mykey.ppk`. It worked with the relative path as well. Thanks so much, you saved my day :) – phpPhil May 29 '15 at 07:30
  • @phpPhil Great! I have included your conclusion in the answer for more visibility. – VonC May 29 '15 at 08:30
  • Thanks for that. Little correction as I can't edit my comment... it should read `IdentityFile ~/.ssh/mykey.pub`. **pub** instead of ppk. – phpPhil May 31 '15 at 23:12