【发布时间】:2016-04-27 20:27:57
【问题描述】:
我的 deploy.rb 中有以下设置
set :application, 'sample_app'
set :repo_url, 'user@123.45.67.100:/home/user/railsapps/sample_app'
set :deploy_to, '/var/www/sample_app'
set :user, "user"
set :ssh_options, { :forward_agent => true }
还有我的 deploy/production.rb 文件:
set :stage, :production
server '123.45.67.200', user: 'user', roles: %w{app db web}
运行 cap production deploy 时出现以下错误:检查
DEBUG [] ssh: connect to host 123.45.67.100 port 22: Connection timed out
DEBUG [] fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user@123.45.67.200: git exit status: 128
git stdout: Nothing written
git stderr: ssh: connect to host 123.45.67.200 port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
在其中一行中,我看到它尝试以 user@123.45.67.200 身份访问存储库,这是生产服务器的部署用户:
INFO [] Running /usr/bin/env git ls-remote --heads user@123.45.67.100:/home/user/railsapps/sample_app as user@123.45.67.200
不应该说它以本地用户的身份使用本地 ssh 密钥连接吗? Capistrano 是否登录到生产服务器,然后从存储库中提取代码?如果是,有没有办法让它将代码从存储库推送到生产服务器?
【问题讨论】:
-
Capistrano 通过拉取更新的代码来工作。它将登录到生产服务器,然后从那里执行 git pull。如果您要转发密钥,则您的本地密钥将可用,但请检查您是否可以以部署用户身份克隆存储库
标签: ruby-on-rails ruby-on-rails-4 ssh capistrano capistrano3