gpt4 book ai didi

ruby-on-rails - Capistrano 部署 -- Net::SSH::AuthenticationFailed -- AWS EC2

转载 作者:行者123 更新时间:2023-12-03 22:23:52 25 4
gpt4 key购买 nike

当我尝试运行部署设置时,为什么会出现 authenicationFailed?我使用 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)

部署文件
# 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

数据库.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'
}

关于ruby-on-rails - Capistrano 部署 -- Net::SSH::AuthenticationFailed -- AWS EC2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10627313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com