【发布时间】:2019-02-24 18:07:07
【问题描述】:
我想使用 capistrano 部署我的应用程序。
我可以使用ssh my_app_stag 连接到服务器,但是当我尝试使用docker-compose run web cap staging deploy 时出现此错误:
D,[2018-09-21T11:46:40.858453 #1] 调试 -- net.ssh.authentication.agent[ac989c]:连接到 ssh-agent
E,[2018-09-21T11:46:40.858662 #1] 错误 -- net.ssh.authentication.agent[ac989c]:无法连接到 ssh-agent:代理未配置
E,[2018-09-21T11:46:40.859037 #1] 错误 -- net.ssh.authentication.session[3f9c0e0cac1c]:所有授权方法都失败(尝试公钥) (回溯仅限于导入的任务) 上限中止!
SSHKit::Runner::ExecuteError: 以 ubuntu@34.244.167.85 身份执行时出现异常:用户 ubuntu@34.244.167.85 身份验证失败
原因: Net::SSH::AuthenticationFailed: 用户 ubuntu@34.244.167.85 认证失败
任务:TOP => rvm:hook (通过使用 --trace 运行任务查看完整跟踪)
我正在使用 pem 密钥进行身份验证,该密钥位于 .ssh/app_name.pem(当我克隆应用程序时,此密钥已包含在 repo 中。所以我没有自己生成它)
ssh/配置
Host my_app_stag
ForwardAgent yes
Hostname my_Ip_adress
User ubuntu
IdentityFile /Users/my_name/.ssh/app_name.pem
deploy.rb
lock '3.10.0'
set :rvm_ruby_version, '2.3.3'
set :default_stage, 'staging'
set :stages, %w(staging production)
set :application, 'app_name'
set :repo_url, 'git@github.com:my_account/app_name.git'
set :full_app_name, "#{fetch(:application)}"
set :user, 'ubuntu'
set :use_sudo, false
# Default branch is :master
set :branch, fetch(:branch, "master")
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, "/var/www/apps/#{fetch(:full_app_name)}"
# Default value for :scm is :git
set :ssh_options, {
auth_methods: %w[publickey],
keys: %w(~/.ssh/app_name.pem),
:verbose => :debug
}
set :use_agent, false
set :pty, true
[]).push('config/database.yml', 'config/secrets.yml')
set :linked_files, %w{config/database.yml config/unicorn_init.sh config/unicorn.rb log/session.secret}
set :linked_dirs, %w{log tmp/pids public/assets public/images/promotions public/images/logo public/images/offers public/images/vehicules public/import_logs sitemaps}
# Default value for keep_releases is 5
set :keep_releases, 5
set :bundle_bins, %w{gem rake ruby}
set(:config_files, %w(
nginx.conf
database.yml
unicorn.rb
unicorn_init.sh
))
set(:executable_config_files, %w(
unicorn_init.sh
))
set(:symlinks, [
{
source: "nginx.conf",
link: "/etc/nginx/sites-enabled/#{fetch(:full_app_name)}"
},
{
source: "unicorn_init.sh",
link: "/etc/init.d/unicorn_#{fetch(:full_app_name)}"
}
])
# set :linked_dirs, %w(public/system log tmp)
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp', 'vendor/bundle', 'public/system')
staging.rb
server 'ip_server', user: 'ubuntu', roles: %w(app db web), primary: true
set :stage, :staging
set :rails_env, 'staging'
set :branch, 'develop'
我试过这个article,但还是不行。
【问题讨论】:
标签: ruby-on-rails ssh deployment capistrano