这是我的Capistrano文件:
set :application, "mydemoapp"
set :repository, "git@bitbucket.org:sergiotapia/mydemoapp.git"
set :scm, :git
set :user, "serg" # The user on the VPS server.
set :use_sudo, false
set :deploy_to, "/opt/nginx/html/#{application}"
set :deploy_via, :remote_cache
set :keep_releases, 1
set :rails_env, "production"
set :migrate_target, :latest
role :web, "192.168.1.1" # Your HTTP server, Apache/etc
role :app, "192.168.1.1" # This may be the same as your `Web` server
role :db, "192.168.1.1", :primary => true # This is where Rails migrations will run
上面的IP地址显然都是假的,我正在使用IP作为我的VPS 现实生活中的服务器。
我运行此命令,以验证BitBucket是否允许我访问存储库:
sergiotapia@jarvis1:~/.ssh$ ssh -T hg@bitbucket.org
conq: logged in as sergiotapia.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
但是,再次运行cap deploy
,我得到:
[198.211.101.99] executing command
** [192.168.1.1:: err] Permission denied (publickey).
** [192.168.1.1:: err] fatal: The remote end hung up unexpectedly
command finished in 1026ms
*** [deploy:update_code] rolling back
* executing "rm -rf /opt/nginx/html/demoapp/releases/20130601025656; true"
我尝试从我的SSH终端手动使用git clone
,它按预期正常工作。我的项目正确克隆到了一个文件夹。
似乎Capistrano正在运行sudo git clone
而不是git clone
。我在SSH上手动在同一文件夹中运行sudo git clone
验证了这一点。相同Permission denied (publickey)
错误。
为什么我的Capistrano设置不被:use_sudo, false
使用?