Github 在Chef中部署私有回购:我的部署密钥有什么问题?
我正在使用chef部署rails/node应用程序。当我从公共github存储库部署时,一切都很好。不过,我想从一个私有的github存储库进行部署,但在这样做时遇到了困难。以下是我目前正在做的事情Github 在Chef中部署私有回购:我的部署密钥有什么问题?,github,ssh-keys,chef-infra,Github,Ssh Keys,Chef Infra,我正在使用chef部署rails/node应用程序。当我从公共github存储库部署时,一切都很好。不过,我想从一个私有的github存储库进行部署,但在这样做时遇到了困难。以下是我目前正在做的事情 cd ~/.ssh # change directory to my .ssh directory ssh-keygen -f'deploy_key' -N '' # create a deploy_key key pair without a pas
cd ~/.ssh # change directory to my .ssh directory
ssh-keygen -f'deploy_key' -N '' # create a deploy_key key pair without a passphrase
cat deploy_key.pub | pbcopy # copy the public key into my clipboard
-go to https://github.com/HairyMezican/PrivateRepoName/admin/keys
-click on 'Add another deploy key'
-type 'deploy_key' into 'Title' field
- ⌘V (paste command) into 'Key' field
-click 'Add Key'
tr "\n" "#" < deploy_key | sed 's/#/\\n/g' | pbcopy #copy the private key into my clipboard, except with all of the newlines replaced with a slash-n
cd ~/chef-repo #change over the the chef repo directory
mate data_bags/apps/my_app.json #edit the appropriate data bag in TextMate
--set the following couple of lines before saving
-"repository": "https://HairyMezican@github.com/HairyMezican/PrivateRepoName.git",
-"deploy_key": "⌘V (paste command into here)",
knife data bag from file apps data_bags/apps/my_app.json #upload the databag to my chef server
ssh root@12.34.56.789 "mkdir ~/.ssh" #create a ssh directory on my remote server
scp ~/.ssh/id_dsa root@12.34.56.789:.ssh/ #copy my private key over to the ssh directory on the remote server
cat ~/.ssh/id_dsa.pub | ssh root@12.34.56.789 'cat - >> ~/.ssh/authorized_keys' #add my public key into the authorized keys list on the remote server
knife bootstrap 12.34.56.789 -dubuntu10.04-gems -rrole[myapp] #tell my chef server to bootstrap the remote server
然后几乎冻结(从技术上讲,我仍然可以键入,但我键入的内容不会影响脚本),直到10分钟后
12.34.56.789 [Sat, 03 Dec 2011 01:51:51 +0000] ERROR: deploy_revision[myapp] (application::rails line 155) has had an error
12.34.56.789 [Sat, 03 Dec 2011 01:51:51 +0000] ERROR: deploy_revision[myapp] (/var/chef/cache/cookbooks/application/recipes/rails.rb:155:in `from_file') had an error:
12.34.56.789 deploy_revision[myapp] (application::rails line 155) had an error: command timed out:
然后在stdout和stderr中列出一个空白输出,以及试图运行该命令的堆栈跟踪
我做错了什么?如何从私有存储库进行部署?您需要在github上创建一个部署密钥,该密钥允许您从私有回购中提取,而无需输入密码短语 见以下网址的文档:
如果这是一个私有的repo,那么您应该使用以开始的git repo的SSH路径git@github.com也是 git@github.com:HairyMezican/PrivateRepoName.git
git@github.com:HairyMezican/PrivateRepoName.git你做得对。注意cookbooks/application/recipes/rails.rb的第85行:
not_if do::File.exists?(“#{app['deploy_to']}/id_deploy”);结束
也就是说,尝试手动登录实例并删除(可能是空白的)id_部署文件,然后重新初始化进程
^_^看来您的ssh密钥正在请求解释,以便它可以连接到github。您可以尝试在不进行解释的情况下重新生成密钥,然后使用吗?注意:在ssh密钥中不使用转述是一种安全风险。您不能将ssh密钥与HTTPS方案一起使用,因此情况并非如此。 git@github.com:HairyMezican/PrivateRepoName.git