When deploying an application with Chef, I\'ve got the code base set to be cloned from a private github repository with the following resource:
git \'/mnt/ap
We use the similar setup for Mercurial, but it should be the same with Git, I hope.
We use ssh keys to authenticate. The key is stored in encrypted databag (with newlines replaced by "\n"). First of all this private key is created on the node from databag.
git_key = Chef::EncryptedDataBagItem.load( "private_keys", "git_key" )
file "/some/path/id_rsa" do
content git_key['private']
end
And then use it when connecting to git repository using ssh_wrapper:
git "/opt/mysources/couch" do
repository "git://git.apache.org/couchdb.git"
reference "master"
action :sync
ssh_wrapper "ssh -i /some/path/id_rsa" #the path to our private key file
end