我在尝试将rails应用程序部署到朋友的服务器时遇到权限错误。我正在运行rails 3.1.3,ruby-1.9.2-p290,capistrano 2.11.2,Mac OS 10.6.8,我们设置了ssh密钥。但是,我们无法确定权限问题的来源。我们认为可能是capistrano试图将代码从git repo作为GIT用户推送到部署目录,或类似的东西。但这是我们的第一次部署尝试,所以我们不确定。任何帮助都将非常感激!
哦,这是我的朋友告诉我指定的更多细节: appsrv-04.example.ca是主机的规范FQDN,project.example.ca是指向appsrv-04.example.ca的A记录的CNAME。 git和deploy用户的known_hosts文件包含所有appsrv-04,appsrv-04.example.ca,project和project.example.ca。
以下是运行上限部署的输出:更新。
[user@workstation]~/Code/projectapi $ cap deploy:update
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git master"
Enter passphrase for key '/Users/user/.ssh/id_rsa':
command finished in 4478ms
* executing "if [ -d /usr/local/www/sites/project.example.ca/public/shared/cached-copy ]; then cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e71d220f299271522517f7b4f028a9275d53326a && git clean -q -d -x -f; else git clone -q ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git /usr/local/www/sites/project.example.ca/public/shared/cached-copy && cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git checkout -q -b deploy e71d220f299271522517f7b4f028a9275d53326a; fi"
servers: ["project.example.ca"]
Enter passphrase for /Users/user/.ssh/id_dsa:
[project.example.ca] executing command
** [project.example.ca :: err] Permission denied, please try again.
** [project.example.ca :: err] Permission denied, please try again.
** [project.example.ca :: err] Permission denied (publickey,password).
** [project.example.ca :: err] fatal: The remote end hung up unexpectedly
command finished in 650ms
*** [deploy:update_code] rolling back
* executing "rm -rf /usr/local/www/sites/project.example.ca/public/releases/20120222225453; true"
servers: ["project.example.ca"]
[project.example.ca] executing command
command finished in 465ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2-p290@project' -c 'if [ -d /usr/local/www/sites/project.example.ca/public/shared/cached-copy ]; then cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e71d220f299271522517f7b4f028a9275d53326a && git clean -q -d -x -f; else git clone -q ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git /usr/local/www/sites/project.example.ca/public/shared/cached-copy && cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy && git checkout -q -b deploy e71d220f299271522517f7b4f028a9275d53326a; fi'" on project.example.ca
这是我的部署文件:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :application, "Project"
set :scm, "git"
set :repository, "ssh://git@appsrv-04.example.ca/usr/local/git_root/project.git"
set :user, "deploy"
#set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_ruby_string, "1.9.2-p290@project"
ssh_options[:forward_agent] = true
set :branch, "master"
set :deploy_via, :remote_cache
set :deploy_to, "/usr/local/www/sites/project.example.ca/public/"
set :use_sudo, false
set :domain, 'project.example.ca'
role :app, domain
role :web, domain
role :db, domain, :primary => true
答案 0 :(得分:14)
你几乎肯定正确地诊断了这个问题;您正在尝试以部署用户身份检出github存储库,并且未正确设置转发的密钥。看起来你在Capistrano中打开了forward_agent ...你是否在你的代理中添加了你的密钥以便正确转发?
尝试使用ssh-add ~/.ssh/id-rsa
并再次部署。
答案 1 :(得分:0)
问题解决了。通过克隆现有虚拟主机并更改IP来创建虚拟主机。我更新了/ etc / hosts文件以使用新的主机名,但显然不是新的IP。因此,当部署用户尝试ssh作为git用户时...它失败了,因为它正在使用的IP上没有git用户。