我需要 Capistrano 使用 2 个不同的 SSH key 。一个用于 git 存储库,一个用于要部署到的服务器。
无论我在 .ssh 文件夹中将哪个 key 重命名为 id_rsa,都可以使用。另一个没有。如果我将 git key 重命名为 id_rsa,Capistrano 可以连接到 git 存储库,但无法在要部署的服务器上进行身份验证。如果我将其命名为其他名称,它将无法连接到 git 存储库。我知道另一个 key 有效,因为我可以执行 ssh -i ~/.ssh/otherKey.pem 并且它将成功连接到服务器。
这就是我的 deploy.rb Capistrano 文件中的内容。
ssh_options[:keys] = [
File.join(ENV["HOME"], ".ssh", "id_rsa"),
File.join(ENV["HOME"], ".ssh", "deploy")
]
ssh_options[:forward_agent] = true
我如何告诉 Capistrano 使用这两个键?它似乎只使用名为 id_rsa 的那个。
编辑:
这是来自 Capistrano 的输出以及错误消息:
$ cap yii deploy
* executing `yii'
Yii
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote git@project.beanstalkapp.com:/projectyii.git HEAD"
* executing "git clone -q git@project.beanstalkapp.com:/projectyii.git /var/www/projectyii-trunk/releases/20110824174629 && cd /var/www/projectyii-trunk/releases/20110824174629 && git checkout -q -b deploy 5e14521285ca04a605353e97bdf31c3a2889dbfb && (echo 5e14521285ca04a605353e97bdf31c3a2889dbfb > /var/www/projectyii-trunk/releases/20110824174629/REVISION)"
servers: ["yii.project.com"]
[yii.project.com] executing command
** [yii.project.com :: err] Error reading response length from authentication socket.
** [yii.project.com :: err] Permission denied (publickey,keyboard-interactive).
** [yii.project.com :: err] fatal: The remote end hung up unexpectedly
command finished
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/projectyii-trunk/releases/20110824174629; true"
servers: ["yii.project.com"]
[yii.project.com] executing command
command finished
failed: "sh -c \"git clone -q git@project.beanstalkapp.com:/projectyii.git /var/www/projectyii-trunk/releases/20110824174629 && cd /var/www/projectyii-trunk/releases/20110824174629 && git checkout -q -b deploy 5e14521285ca04a605353e97bdf31c3a2889dbfb && (echo 5e14521285ca04a605353e97bdf31c3a2889dbfb > /var/www/projectyii-trunk/releases/20110824174629/REVISION)\"" on yii.project.com
编辑:
另一件事:它在我的本地机器上完全可以正常工作,只是在部署服务器上不行——使用完全相同的配置文件! Capistrano 似乎在我的本地机器上使用了正确的 key ,但在部署机器上却没有。
最佳答案
免责声明:我对 Capistrano 一无所知。
如果它只是简单地执行正常的 ssh 调用(或调用 git 来执行此操作),您可以配置正确的 key 以在您的 ~/.ssh 中使用/config 基于每个主机(或每个主机别名)。
例如,我的 ~/.ssh/config 文件中有这些行:
# Git bei Github
Host github.com
User git
IdentityFile ~/.ssh/svn_id_rsa
# Andere Mathe-Hosts
Host *.math.hu-berlin.de
User ebermann
IdentityFile ~/.ssh/id_rsa
ControlMaster auto
关于git - Capistrano 和几个 SSH key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7154161/
我尝试使用不同的ssh_options在同一阶段运行capistranov.3任务。我的production.rb说:set:stage,:productionset:user,'deploy'set:ssh_options,{user:'deploy'}通过此配置,capistrano与用户deploy连接,这对于其余的任务是正确的。但是我需要将它连接到服务器中配置良好的an_other_user以完成一项特定任务。然后我的食谱说:...taskswithoriginaluser...task:my_task_with_an_other_userdoset:user,'an_othe
文章目录git常用命令(简介,详细参数往下看)Git提交代码步骤gitpullgitstatusgitaddgitcommitgitpushgit代码冲突合并问题方法一:放弃本地代码方法二:合并代码常用命令以及详细参数gitadd将文件添加到仓库:gitdiff比较文件异同gitlog查看历史记录gitreset代码回滚版本库相关操作远程仓库相关操作分支相关操作创建分支查看分支:gitbranch合并分支:gitmerge删除分支:gitbranch-ddev查看分支合并图:gitlog–graph–pretty=oneline–abbrev-commit撤消某次提交git用户名密码相关配置g
关于SSHkit-Github它说:Allbackendssupporttheexecute(*args),test(*args)&capture(*args)来自SSHkit-Rubydoc,我明白execute实际上是test的别名?test之间有什么区别?,execute,capture在Capistrano/SSHKit中我应该什么时候使用? 最佳答案 执行只是执行命令。使用非0退出引发错误。测试方法的行为与execute完全相同,但是它返回bool值(true如果命令以0退出,而false否则)。它通常用于控制任务中的流程
关于如何使用git设置类似Dropbox的服务,您有什么建议吗?您认为git是解决此问题的合适工具吗?我在考虑使用git+rush解决方案,你觉得怎么样? 最佳答案 检查这个开源项目:https://github.com/hbons/SparkleShare来自项目的自述文件:Howdoesitwork?SparkleSharecreatesaspecialfolderonyourcomputer.Youcanaddremotelyhostedfolders(or"projects")tothisfolder.Theseprojec
我编写了一个非常简单的“部署”脚本,作为我的裸git存储库中的post-updateHook运行。变量如下livedomain=~/mydomain.comstagingdomain=~/stage.mydomain.comgitrepolocation=~/git.mydomain.com/thisrepo.git(bare)core=~/git.mydomain.com/thisrepo.gitcore==addedremoteintoeachlive&stagegitslive和stage都初始化了gitrepos(非裸),我已经将我的裸仓库作为远程添加到它们中的每一个(名为co
我正在安装gitlabhq,并且在Gemfile中有对某些资源的“git://...”的引用。但是,我在公司防火墙后面,所以我必须使用http://。我可以手动编辑Gemfile,但我想知道是否有另一种方法告诉bundler使用http://作为git存储库? 最佳答案 您可以通过运行gitconfig--globalurl."https://".insteadOfgit://或通过将以下内容添加到~/.gitconfig:[url"https://"]insteadOf=git://
我想用Capistrano启动sidekiq。下面是代码namespace:sidekiqdotask:startdorun"cd#{current_path}&&bundleexecsidekiq-c10-eproduction-Llog/sidekiq.log&"pcapture("psaux|grepsidekiq|awk'{print$2}'|sed-n1p").strip!endend它执行成功但sidekiq仍然没有在服务器上启动。输出:$capsidekiq:starttriggeringloadcallbacks*2014-06-0315:03:01executing`
Activeadmingem已添加到我的rails项目中,但每次我尝试安装railsgactive_admin:install时,我都会收到类似的错误git://github.com/activeadmin/activeadmin.git(atmaster)isnotyetcheckedout.Runbundleinstallfirst.我肯定在运行“railsgactive_admin:install”之前运行了bundle。运行“bundleshow”后,我看到我已将“*activeadmin(1.0.0.pre3f916d6)”添加到我的项目中,但不断收到此错误消息。我的gem文
我有一个字符串变量,它只能包含6个不同的值。我想检查它是否包含前4个值之一或2个第二值之一。有没有比这更优雅的方式:ifstring.eql?'val1'||string.eql?'val2'||string.eql?'val3'||string.eql?'val4'...elsifstring.eql?'val5'||string.eql?'val6'...end可能类似于ifstringisin['val1','val2','val3','val4']? 最佳答案 您可以使用include?:if['val1','val2','
如何使用Capistrano将Rails应用程序部署到无法访问外部网络或存储库的生产或暂存服务器?我已经设法完成部署的一半,并意识到Capistrano没有在我的本地机器上下载gitrepo,但它首先连接到远程服务器并尝试在那里下载Git存储库。我希望有一个类似Javaee的构建系统,其中创建可交付成果并将该可交付成果发送到服务器。就像您构建.ear文件并将其部署到您想要的任何服务器上一样。显然在RoR中,你被迫(据我所知)在该服务器上构建应用程序,在那里创建一个gem存储库,在那里克隆最新的分支等等。有什么方法可以将准备运行的包发送到远程服务器吗? 最佳答