Ruby on rails GitHub通过Capistrano部署。公共回购和SSH有效,但私有回购和SSH无效;T
我真的需要你的帮助。我在本地机器上有一个RubyonRails应用程序,在GitHub有一个存储库,还有一个Ubuntu服务器,它用Nginx托管该应用程序 我把我的回购协议公开了很长一段时间,通过capistrano进行的部署效果很好。现在我把我的回购协议转换成了私有协议,但部署根本不起作用。当我尝试部署它时,会出现以下错误:Ruby on rails GitHub通过Capistrano部署。公共回购和SSH有效,但私有回购和SSH无效;T,ruby-on-rails,git,deployment,github,capistrano,Ruby On Rails,Git,Deployment,Github,Capistrano,我真的需要你的帮助。我在本地机器上有一个RubyonRails应用程序,在GitHub有一个存储库,还有一个Ubuntu服务器,它用Nginx托管该应用程序 我把我的回购协议公开了很长一段时间,通过capistrano进行的部署效果很好。现在我把我的回购协议转换成了私有协议,但部署根本不起作用。当我尝试部署它时,会出现以下错误: * executing `deploy' * executing `deploy:update' ** transaction: start * exec
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git://github.com/GIT_USER/APPLICATION.git master"
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/APPLICATION/releases/DATE_OF_DEPLOY; true"
servers: ["DOMAIN"]
[DOMAIN] executing command
command finished in 424ms
所以,我的猜测是,身份验证不起作用,但确实起作用了。我将公钥复制到GitHub,甚至可以在那里使用SSH。我可以从服务器SSH到GitHub,它说我已成功通过身份验证。我甚至可以看到哪个键起作用。但是“gitlsremote[…]”不起作用,除了我已经得到的信息之外,我没有通过trace运行它得到任何信息
所以,我的主要问题是我不知道在哪里可以找到错误。如果你知道如何解决这个问题,或者你可以把我的问题指向任何方向,那就好了
这是my deploy.rb的主要部分:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
require 'bundler/capistrano'
default_run_options[:pty] = true
set :user, "DEPLOY_USER"
set :domain, "DOMAIN"
set :application, "APPLICATION"
set :repository, "git@github.com:GIT_USER/APPLICATION.git"
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :remote_cache
set :scm, :git
set :git_account, "GIT_USER"
set :branch, "master"
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false
set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_ruby_string, '1.9.2'
set :rvm_type, :user # Don't use system-wide RVM
ssh_options[:port] = PORT_NUMBER
set :user, user
ssh_options[:keys] = %w(/home/DEPLOY_USER/.ssh/id_rsa)
set :ssh_options, { :forward_agent => true}
server domain, :app, :web
# Your HTTP server, Apache/etc
role :web, domain
# This may be the same as your `Web` server
role :app, domain
# This is where Rails migrations will run
role :db, domain, :primary => true
很抱歉,这个东西看起来很凌乱,但我尝试了很多提示、技巧和教程
谢谢你的帮助
顺便说一句:是的,所有用Capslock编写的东西都是出于隐私原因,当然,它们不是我使用的真实设置。我似乎记得在使用私有github repo进行部署时遇到过类似的问题。我认为我们还没有完全解决问题的原因,但最终我认为我们通过使用
ssh add
将github密钥添加到ssh代理解决了问题-可能值得一试因为这是一种非公开的回购,您应该使用git@... 地址
我看到您的deploy.rb文件中有这个,但是ls remote仍然在上执行git://...
问题可能是服务器上存储库的缓存副本。检查共享/缓存的copy/.git/config文件中的源地址是否正确。你应该git@... 而不是git://... 有对于私人回购,您必须使用https样式:
set :repository, "https://github.com/git_name/repo_name.git"
。。但每次部署时,您必须输入两次用户名和密码!
所以我写了一个小脚本,希望能为我做到这一点
看看这个
。。或作为演练:
1-在主目录中创建一个文件($cat>~/git\u cap)
2-使其可执行
3-在.profile/.bashrc.中添加别名。。(可选)
4-将sudo pwd添加到deploy.rb或扩展sudo pwd的expect脚本
(由于这个原因,用户名和密码预期会出现2次,即使可能会使用更多次。。但通过这种方式,您可以添加一行密码,并使用exp_continue,以便下一个密码都会发送sudo pwd,而不是git pwd)
5-使用gcap部署
只是想检查一下,我们在哪里看到“GIT_用户”、“应用程序”等。在问题中,您已经将其替换为堆栈溢出隐私?是的,这些不是我真正的设置。只是为了保护隐私而更换了它们。
#!/usr/bin/expect -f
# Expect script to supply username/password to cap deploy to git private repository
# This script needs username and password as arguments to connect to git server:
# ------------------------------------------------------------------------
# ./git_cap gituser gitpwd
# -------------------------------------------------------------------------
# set Variables
set g_user [lrange $argv 0 0]
set g_pwd [lrange $argv 1 1]
set timeout -1
spawn cap deploy
match_max 100000
# Look for user prompt
expect "*?sername:*"
send -- "$g_user\r"
send -- "\r"
# Look for passwod prompt
expect "*?assword:*"
send -- "$g_pwd\r"
send -- "\r"
# Look for user prompt
expect "*?sername:*"
send -- "$g_user\r"
send -- "\r"
# Look for passwod prompt
expect "*?assword:*"
send -- "$g_pwd\r"
send -- "\r"
expect eof
$ chmod 755 ~/git_cap
$ chmod +x ~/git_cap
alias gcap='~/git_cap gitname gitpwd'
rails_root$ gcap