简体   繁体   English

Rails:Capistrano。 被拒绝(公钥)

[英]Rails : Capistrano. Permisssion Denied(public key)

I've been looking at a way to deploy my app using capistrano. 我一直在寻找一种使用capistrano部署我的应用程序的方法。 I currently am hosting a small private repo on github and a local server to try deploying my test. 我目前正在github和本地服务器上托管一个小型私人仓库来尝试部署我的测试。 I come upon a problem and an error message below. 我遇到了一个问题和下面的错误信息。

I have done the following 我做了以下事情

  1. Generate an ssh key on server and added it sucessfully to deploy keys in repo and tested(git@github.com) 在服务器上生成一个ssh密钥并成功添加它以在repo中部署密钥并进行测试(git@github.com)

  2. Generate an ssh key on client and add it sucessfully to deploy keys in repo 在客户端生成一个ssh密钥并成功添加它以在repo中部署密钥

  3. setup a private repository. 设置私有存储库。 And have account deployer with rights to deploy 并且拥有部署权限的帐户部署者

  4. configed deploy.rb and production rb to follow mimic many other templates out there. configed deploy.rb和production rb跟随模仿许多其他模板。

I still cannnot figure why it is giving me an error like this 我仍然无法理解为什么它会给我这样的错误

    DEBUG [a5554d3d] Command: /usr/bin/env chmod +x /tmp/App/git-ssh.sh
    INFO [a5554d3d] Finished in 0.020 seconds with exit status 0 (successful).
    INFO [b1517df1] Running /usr/bin/env git ls-remote --heads git@github.com:aceofw
    ings/App.git as deploy@192.168.1.84
    DEBUG [b1517df1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/App/git-ssh
    .sh /usr/bin/env git ls-remote --heads git@github.com:aceofwings/App.git )

    DEBUG [b1517df1]        Permission denied (publickey).
    DEBUG [b1517df1]        fatal: Could not read from remote repository.
    DEBUG [b1517df1]
    DEBUG [b1517df1]        Please make sure you have the correct access rights
    DEBUG [b1517df1]        and the repository exists.
    (Backtrace restricted to imported tasks)
    cap aborted!
    SSHKit::Runner::ExecuteError: Exception while executing as deploy@192.168.1.84:
    git exit status: 128
    git stdout: Nothing written
    git stderr: Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

    SSHKit::Command::Failed: git exit status: 128
    git stdout: Nothing written


The Deploy.rb file Deploy.rb文件

   ###############Deploy.rb##################
# config valid only for current version of Capistrano
lock '3.4.0'

set :repo_url, 'git@github.com:aceofwings/App.git'
set :application, 'App'
set :user, 'deploy'
#set :pty, true
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp



# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')


namespace :deploy do

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end


Production.rb Production.rb

server '192.168.1.84', user: 'deploy', roles: %w{app db web}

#set :stage, :production
 role :app, %w{deploy@192.168.1.84}
 role :web, %w{deploy@192.168.1.84}
 role :db,  %w{deploy@192.168.1.84}


  set :ssh_options, {
    forward_agent: false,
    auth_methods: %w(password),
    password: 'Deploy4Real',
    user: 'deploy'
  }

I had a similar problem. 我遇到了类似的问题。 It turns out that the SSH agent was not running. 事实证明SSH代理没有运行。 I found this out looking at the Capistrano documentation: http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/ 我发现了这个看Capistrano文档: http//capistranorb.com/documentation/getting-started/authentication-and-authorisation/

Running this command: 运行此命令:

$ ssh-add -l $ ssh-add -l

showed me that my public key was not added to the agent so I had to add it: 告诉我,我的公钥没有添加到代理,所以我不得不添加它:

$ ssh-add $ ssh-add

Identity added: /Users/me/.ssh/id_rsa (/Users/me/.ssh/id_rsa) 身份添加:/Users/me/.ssh/id_rsa(/Users/me/.ssh/id_rsa)

After this my Capistrano deployment worked. 在此之后,我的Capistrano部署工作。

You should set in production.rb: 你应该在production.rb中设置:

forward_agent: true

I was having the same problem with Capistrano 3.4. 我与Capistrano 3.4有同样的问题。 With Capistrano 3.2.1 it seemed to ignore this parameter. 使用Capistrano 3.2.1,它似乎忽略了这个参数。

You can use capistrano-ssh-doctor to troubleshoot possible config problems. 您可以使用capistrano-ssh-doctor来解决可能的配置问题。

I think your capistrano may have some old files in its git cache, probably from renaming the repository or something like that. 我认为你的capistrano可能在它的git缓存中有一些旧文件,可能来自重命名存储库或类似的东西。 Try to delete the cached-copy folder in the shared folder on the server, so capistrano will pull your repo again. 尝试删除服务器上shared文件夹中的cached-copy文件夹,因此capistrano将再次拉回您的存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过Capistrano进行GitHub部署。 Public Repo和SSH有效,但Private不起作用 - GitHub Deploy via Capistrano. Public Repo and SSH works, but Private doesn't 我正在使用 Capistrano 部署 Rails6 应用程序。 部署失败 - I am deploying Rails6 app using Capistrano. Deploying fails 无法使用capistrano部署rails4项目。 rbenv:未安装版本“2.0.0” - Can't deploy rails4 project with capistrano. rbenv: version `2.0.0' is not installed 使用Capistrano部署Rails应用-权限被拒绝(公钥) - Deploying Rails app with Capistrano - Permission denied (publickey) Capistrano +每当宝石 - bin / rails:权限被拒绝 - Capistrano + Whenever gems - bin/rails: Permission denied Rails,Capistrano和Dreamhost - 密钥验证失败 - Rails, Capistrano, and Dreamhost — Key Verification Failure Capistrano Rails部署-SSH密钥未通过身份验证的口令 - Capistrano rails deploy - passphrase for SSH key not authenticating 防止公共文件夹中的某些文件夹被删除capistrano rails - Prevent certain folder in public folder from being removed capistrano rails Capistrano部署配方以符号链接Ruby on Rails文件夹public / images,不起作用 - Capistrano Deploy recipe to symlink Ruby on Rails folder public/images, not working Capistrano-Rails错误:无法访问日志文件+独角兽:权限被拒绝 - Capistrano - Rails Error: Unable to access log file + unicorn: Permission denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM