ruby-on-rails - 为什么我在尝试限制部署时得到 "Permission Denied"?

标签 ruby-on-rails git capistrano

我正在尝试使用服务器上的远程 git 存储库通过 capistrano 部署我的 Rails 4 应用程序。我的 git repo 在我部署我的应用程序的同一台服务器上。每当我尝试 cap deploy 时,我都会收到此错误

my/local/rails/app/directory$ cap deploy
    triggering load callbacks
  * 2013-08-30 15:51:20 executing `deploy'
  * 2013-08-30 15:51:20 executing `deploy:update'
 ** transaction: start
  * 2013-08-30 15:51:20 executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote ssh://git@myserver.com/var/repos/test.git master"
    command finished in 684ms
  * executing "if [ -d /var/www/test/www/shared/cached-copy ]; then cd /var/www/test/www/shared/cached-copy && git fetch  origin && git fetch --tags  origin && git reset  --hard 9de1df43a7959b953dc0b35c2ab27ba84698602a && git clean  -d -x -f; else git clone -b master ssh://git@myserver.com/var/repos/test.git /var/www/test/www/shared/cached-copy && cd /var/www/test/www/shared/cached-copy && git checkout -b deploy 9de1df43a7959b953dc0b35c2ab27ba84698602a; fi"
    servers: ["myserver.com"]
    [myserver.com] executing command
 ** [myserver.com :: out] Cloning into '/var/www/test/www/shared/cached-copy'...
 ** [myserver.com :: out]
 ** [myserver.com :: out] git@myserver.com's password:
Password: 
 ** [myserver.com :: out]
 ** [myserver.com :: out] Permission denied, please try again.
 ** git@myserver.com's password:
Password: 
 ** [myserver.com :: out]
 ** [myserver.com :: out] Permission denied, please try again.
 ** git@myserver.com's password:
Password: 
 ** [myserver.com :: out]
 ** [myserver.com :: out] Permission denied (publickey,password).
 ** fatal: Could not read from remote repository.
 ** 
 ** Please make sure you have the correct access rights
 ** and the repository exists.
    command finished in 18891ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/test/www/releases/20130830225140; true"
    servers: ["myserver.com"]
    [myserver.com] executing command
    command finished in 700ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-2.0.0-p247' -c 'if [ -d /var/www/test/www/shared/cached-copy ]; then cd /var/www/test/www/shared/cached-copy && git fetch  origin && git fetch --tags  origin && git reset  --hard 9de1df43a7959b953dc0b35c2ab27ba84698602a && git clean  -d -x -f; else git clone -b master ssh://git@myserver.com/var/repos/test.git /var/www/test/www/shared/cached-copy && cd /var/www/test/www/shared/cached-copy && git checkout -b deploy 9de1df43a7959b953dc0b35c2ab27ba84698602a; fi'" on myserver.com

每当我输入密码时,它都会显示权限被拒绝,我确定密码是正确的。这是我的 deploy.rb

require 'bundler/capistrano'
require 'rvm/capistrano'

set :user, 'user'
set :domain, 'myserver.com'
set :application, "blog"
set :repository,  "ssh://git@myserver.com/var/repos/test.git"
set :scm_passphrase, "password"
set :deploy_to, '/var/www/test/www'
set :deploy_via, :remote_cache
set :scm, :git
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false
set :normalize_asset_timestamps, false
set :rails_env, :production

set :rvm_type, :system
set :rvm_ruby_string, 'ruby-2.0.0-p247'
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, domain                         # Your HTTP server, Apache/etc
role :app, domain                         # This may be the same as your `Web` server
role :db,  domain, :primary => true # This is where Rails migrations will run

default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:migrate", "deploy:restart"
after "deploy:update", "deploy:restart"

# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
# namespace :deploy do
#   task :start do ; end
#   task :stop do ; end
#   task :restart, :roles => :app, :except => { :no_release => true } do
#     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
#   end
# end

namespace :deploy do
    desc "cause Passenger to restart"
    task :restart do
        run "touch #{current_path}/tmp/restart.txt"
    end
end

我可以使用 ssh key 从命令行通过 ssh 连接到我的服务器,所以一切正常。有人知道问题出在哪里吗?谢谢。

最佳答案

这在过去对我有用。希望它对你有用:

ssh-add /.ssh/id_rsa

关于ruby-on-rails - 为什么我在尝试限制部署时得到 "Permission Denied"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18542690/

相关文章:

ruby-on-rails - Capistrano 中的角色数组

css - Assets 管道排序 - 重写在生产中不起作用

html - 在 Ruby on Rails 中指定样式表

ruby-on-rails - 获取 "own"所有这些其他记录的所有记录

asp.net - azure 部署问题:do not have permission to view this directory or page

git - Git 如何处理符号链接(symbolic link)?

git - 在 Git 中,delta 是什么意思?

git checkout 抛出致命引用不是树

ruby-on-rails - 使用 Assets 管道优化 Rails 应用程序到多台服务器的部署

ruby-on-rails - 如何升级项目的 Ruby 版本?