Capistrano错误:“无法连接到ssh-agent:未配置代理”

时间:2018-09-20 12:13:36

标签: ruby-on-rails ssh deployment capistrano

我想使用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中(克隆该应用程序时,此密钥已包含在存储库中。因此我没有自行生成该密钥)

ssh / config

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,但仍然无法正常工作。

1 个答案:

答案 0 :(得分:0)

也许将您的ssh-key添加到ssh-agent而不是链接到文件?

ssh-add -K /Users/my_name/.ssh/app_name.pem