用户 Net::SSH::AuthenticationFailed 的身份验证失败

Authentication failed for user Net::SSH::AuthenticationFailed

我正在尝试将我的应用程序部署到 ubuntu 服务器,但出现错误。我已经在服务器授权中添加了我的密钥 keys.I 我正在使用 Google 计算机服务器作为服务器 purpose.I 我无法找到任何解决方案所有解决方案都会导致服务器 ssh 文件夹中的授权密钥并且我已经添加了那。有没有人遇到同样的问题?这是一个代码:

Ayazs-MBP:peatio_exchange ayaz$ cap production deploy
00:00 rbenv:validate
      rbenv: rbenv_ruby is not set; ruby version will be defined by the remote …
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@35.190.186.40: Authentication failed for user deploy@35.190.186.40


Caused by:
Net::SSH::AuthenticationFailed: Authentication failed for user deploy@35.190.186.40

Tasks: TOP => rbenv:map_bins => passenger:rbenv:hook => passenger:test_which_passenger
(See full trace by running task with --trace)
Ayazs-MBP:peatio_exchange ayaz$ 

我的宝石是

group :development do
    gem 'capistrano',         require: false
    gem 'capistrano-rvm',     require: false
    gem 'capistrano-rails',   require: false
    gem 'capistrano-bundler', require: false
    gem 'capistrano3-puma',   require: false
    gem 'capistrano-passenger'
    gem 'capistrano-rbenv', '~> 2.0', require: false
  end

cap 文件是

# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/deploy"

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#   https://github.com/capistrano/passenger
#
require "capistrano/rails"
# require "capistrano/rvm"
require "capistrano/rbenv"
# require "capistrano/chruby"
require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
require "capistrano/passenger"

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Deploy.rb

lock "~> 3.10.1"

set :application, "peatio_exchange"
set :repo_url, "https://github.com/ayazahmadtarar/peatio_exchange.git"

Production.rb

server "35.190.186.40",
  user: "deploy",
  roles: %w{web app},
  ssh_options: {
    user: "deploy", # overrides user setting above
    keys: %w(/home/deploy/.ssh/id_rsa),
    forward_agent: false,
    auth_methods: %w(publickey password)
    # password: "please use keys"
  }

可能有很多原因,但从外观上看,您可能添加的 public 密钥不适用于 deploy 用户。确保它存在于 /home/deploy/.ssh(或其主目录)

确保您能够使用 ssh deploy@35.190.186.40 登录到服务器 — 如果您为部署用户生成了一个单独的密钥,您可以使用 -i 标志来指定到密钥文件。

ssh -i ~/Desktop/deploy_id_rsa.pub deploy@35.190.186.40