ruby-on-rails – Capistrano Deploy – Net :: SSH :: AuthenticationFailed – AWS EC2

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Capistrano Deploy – Net :: SSH :: AuthenticationFailed – AWS EC2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试运行部署设置时,为什么我得到认证失败?我正在使用ssh作为我的密码.我需要更改 database.yml或deploy.rb中的任何内容.它们列在下面.
$cap deploy:setup
  * executing `deploy:setup'
  * executing "sudo -p 'sudo password: ' mkdir -p /var/www/apps/sample_app /var/www/apps/sample_app
 /releases /var/www/apps/sample_app/shared /var/www/apps/sample_app/shared/system /var/www     
/apps/sample_app/shared/log /var/www/apps/sample_app/shared/pids"
    servers: ["ec2-20-21-42-51.compute-1.amazonaws.com"]
Password: 
connection Failed for: ec2-20-21-42-51.compute-1.amazonaws.com 
(Net::SSH::AuthenticationFailed: ubuntu)

deploy.rb

# The name of your app
set :application,"sample_app"

# The directory on the EC2 node that will be deployed to
set :deploy_to,"/var/www/apps/#{application}"

set :keep_releases,3

# deploy with git
set :scm,:git
set :repository,"git@github.com:username/sample_app.git"
set :git_shallow_clone,1
set :branch,"master"
set :use_sudo,true

set :user,"ubuntu"
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

# The address of the remote host on EC2 (the Public DNS address)
set :location,"ec2-20-21-42-51.compute-1.amazonaws.com"

# setup some Capistrano roles
role :app,location
role :web,location
role :db,location,:primary => true

after 'deploy:update_code','deploy:symlink_db'


namespace :deploy do

desc "Restart Application"
task :restart,:roles => :app do
run "touch #{deploy_to}/#{shared_dir}/tmp/restart.txt"
end

desc "Symlinks the database.yml"
task :symlink_db,:roles => :app do
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end

end

database.yml的

development:
  adapter: MysqL2
  database: db/development.MysqL2
  pool: 5
  timeout: 5000
  database: sample_app
  username: root
  socket: /tmp/MysqL.sock

test:
  adapter: MysqL2
  database: db/test.MysqL2
  pool: 5
  timeout: 5000
  database: sample_app
  username: root
  socket: /tmp/MysqL.sock

production:
  adapter: MysqL2
  database: db/production.MysqL2
  pool: 5
  timeout: 5000
  database: sample_app
  username: ubuntu
  socket: /var/run/MysqLd/MysqLd.sock

解决方法

对于Capistrano v2

指定您的pem文件的位置

ssh_options[:keys] = ["/where/ever/it/is/key.pem"]

对于Capistrano v3
ssh_options已略有变化,但基本设置几乎相同.

set :ssh_options,{
  keys: %w(/where/ever/it/is/key.pem),forward_agent: false,user: 'ubuntu'
}
原文链接:https://www.f2er.com/ruby/273362.html

猜你在找的Ruby相关文章