gpt4 book ai didi

ruby-on-rails - 无法运行上限生产部署:使用 Net::SSH::AuthenticationFailed 初始化:用户身份验证失败?

转载 作者:行者123 更新时间:2023-12-02 14:19:41 24 4
gpt4 key购买 nike

我试图将我的rails应用程序从我的mac部署到 digital ocean 上的服务器(使用github)。

所以当我跑cap production deploy:initial我第一次得到这个错误

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke rvm:hook (first_time)
** Execute rvm:hook

cap aborted!
Net::SSH::AuthenticationFailed: Authentication failed for user deploy@myip

/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/net-ssh-4.0.0/lib/net/ssh.rb:250:in `start'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/connection_pool.rb:59:in `call'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/connection_pool.rb:59:in `with'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/netssh.rb:155:in `with_ssh'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/netssh.rb:108:in `execute_command'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `tap'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:55:in `test'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:21:in `block (3 levels) in <top (required)>'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'

但是我已经添加了我的服务器 id_rsa.pub到存储库部署 key 。
当我通过从 ssh key 克隆我的 repo 进行测试时,它可以正常工作,没有任何问题。

这是我的 deploy.rb
# config valid only for current version of Capistrano
lock "3.7.1"

set :repo_url, 'git@github.com:myrepo.git'
set :application, 'appname'
set :user, 'deploy'
set :puma_threads, [4, 16]
set :puma_workers, 0

# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord

namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end

before :start, :make_dirs
end

namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end

desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end

desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end

before :starting, :check_revision
after :finishing, :cleanup
end

那么我该如何解决这个问题?

谢谢!

最佳答案

我不是 ruby​​ 或 capistrano 用户,但是:

set :ssh_options,     { ..., keys: %w(~/.ssh/id_rsa.pub) }
^^^^^^^^^^

您应该在此处指定私钥文件,而不是公钥文件。私钥文件可能是没有“.pub”扩展名的“~/.ssh/id_rsa”。

关于ruby-on-rails - 无法运行上限生产部署:使用 Net::SSH::AuthenticationFailed 初始化:用户身份验证失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41405645/

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