如何使用部署ssh密钥在AWS OpsWorks上使用Chef 12克隆私有回购

时间:2016-01-29 19:37:06

标签: github ssh chef ssh-keys aws-opsworks

我可以在AWS OpsWorks上使用Chef 12克隆公共回购,如下所示:

execute "get code" do
user "root"
cwd node['conf-cookbook']['project_root']
command "git clone #{app['app_source']['url']}"
end

但我不知道如何使用deploy ssh key来克隆私有回购 - 我已经搜索了一段时间并看到了一个潜在的解决方案如下:

git node['conf-cookbook']['app_dir'] do
  repository "ext::ssh -i #{app['app_source']['ssh_key']} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no #{app['app_source']['url']}"
  checkout_branch "master"
  action :sync
end

无法使用错误msg:

---- Begin output of git ls-remote "ext::ssh -i -----BEGIN RSA PRIVATE KEY----
MIIJKQIBAAKCAgEApaViIRinBrusrE....[key detail]7xAOmo3NAmqcPxdrOI+hZJHh5KRvrQPLHY
-----END RSA PRIVATE KEY----- -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no git@github.com:harrywang/app-main.git" "HEAD" ----
STDOUT: 
STDERR: Warning: Identity file -----BEGIN not accessible: No such file or directory.
ssh: Could not resolve hostname rsa: Name or service not known 
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

有任何帮助吗?谢谢!

2 个答案:

答案 0 :(得分:4)

根据@coderanger的建议,以下工作:

[Authorize(Users="MyOneAuthorizedUser")]

答案 1 :(得分:2)

-i获取密钥文件的路径,而不是实际的密钥数据本身。使用application_git食谱与Chef一起设置部署密钥。