Amazon AWS, cap deploy:check fails

2019-08-23 02:46发布

I'm trying to setup deployment to an AWS EC2 instance, using capistrano. In order to test, I'm using

cap testing deploy:check

but Capistrano fails with:

    triggering load callbacks
  * 2013-03-12 15:41:27 executing `testing'
    triggering start callbacks for `deploy:check'
  * 2013-03-12 15:41:27 executing `multistage:ensure'
  * 2013-03-12 15:41:27 executing `deploy:check'
  * executing "test -d /......./releases"
    servers: ["ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com"]
    connection failed for: ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com
    (NoMethodError: undefined method `each' for "publickey":String)

I'm using my .pem file to connect, and the deploy.rb script looks as follows:

set :stages, %w(production testing)
set :default_stage, 'testing'
require 'capistrano/ext/multistage'

set :application, 'app_name'
set :user, 'the_user'
set :group, 'the_group'

set :scm, :git
set :repository,  "git@github.com:......./#{application}.git"
set :deploy_to, '/......./'
set :deploy_via, :remote_cache

# Authentication setup
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
ssh_options[:auth_methods] = 'publickey'
ssh_options[:keys] = ['~/........pem']

Any idea why this is happening?

3条回答
狗以群分
2楼-- · 2019-08-23 03:34

Try putting your public key on the server.

And remove

ssh_options[:auth_methods] = 'publickey'

ssh_options[:keys] = ['~/........pem']

It should work

查看更多
Luminary・发光体
3楼-- · 2019-08-23 03:35

Remove the line

ssh_options[:auth_methods] = 'publickey'
查看更多
Fickle 薄情
4楼-- · 2019-08-23 03:37

I recently upgraded a development server and saw the same behavior. The error message looks as though Capistrano is expecting an iterable and the assignment for publicKey isn't defining it as such.

As trivial as it may sound, try changing:

ssh_options[:auth_methods] = 'publickey'
ssh_options[:keys] = ['~/........pem']

to:

set :ssh_options, {:auth_methods => "publickey"}
set :ssh_options, {:keys => ["~/......pem"]}

You may need to do the same for the other items in your authentication setup. Good luck.

查看更多
登录 后发表回答