capistrano with ubuntu ec2 instance to deploy ruby on rails

半腔热情 提交于 2020-01-06 02:55:07

问题


I am trying to implement ruby on rails app using Capistrano, I am running apache rvm in the staging server and nginx REE version in production server. I am using git also. I have been try to integrate Capistrano but I am getting the this error

(Net::SSH::AuthenticationFailed: ubuntu)

Here is my deploy.rb file

set :application, "capify"

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

set :keep_releases, 3

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

set :user, "ubuntu"
ssh_options[:keys] = ["/path/tp/key.pem"]
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

# The address of the remote host on EC2 (the Public DNS address)
set :location, "ip"

# 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

Unable to figure the exact problem and the methods to integrate capistrano.


回答1:


It seems simple: Capistrano does not prompt for passwords when deploying but rather expects your SSH key to authenticate you on the target server.

It seems like the user you are trying to deploy as (ubuntu) can't be authenticated because of this.

Try adding the contents of your ~/.ssh/id_rsa.pub to the servers: /home/ubuntu/.ssh/authorized_keys file.

If you can ssh into your machine without getting prompted for a password it is working

Update: In your case you are using the ssh_options[:keys] to define another key to be used for SSH authorization. You could either remove that directive to default to your standard ssh key (the one in ~/.ssh/id_rsa.pub) or add that other key you are specifying to the authorized_keys file on your server.

I suggest you try it without the ssh_options[:keys] option :)



来源:https://stackoverflow.com/questions/11097586/capistrano-with-ubuntu-ec2-instance-to-deploy-ruby-on-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!