Capistrano bitbucket-权限被拒绝(公钥) [英] Capistrano bitbucket - Permission denied (publickey)
问题描述
我正在尝试使用Capistrano将我的应用程序部署到我的DigitalOcean服务器上.
I'm trying to deploy my application using Capistrano towards my DigitalOcean server.
这不是我第一次使用Capistrano部署在DigitalOcean上配置RoR服务器,这就是我感到困惑的原因.我的工作流程没有任何更改.
This isn't the first time I've configured a RoR server on DigitalOcean with Capistrano deploys that's why I'm confused; I haven't changed anything in my workflow.
这是我的Capistrano配置文件:
Here is my Capistrano configuration file:
require 'bundler/capistrano'
require 'rvm/capistrano'
set :application, "foobar"
set :repository, "git@bitbucket.org:sergiotapia/foobar.git"
set :ping_url, "http://192.168.1.1/"
set :scm, :git
set :scm_verbose, true
default_run_options[:pty] = true
set :user, "sergiotapia" # The user on the VPS server.
set :password, "hunter2"
set :use_sudo, false
set :deploy_to, "/home/sergiotapia/www/#{application}"
set :deploy_via, :remote_cache
set :keep_releases, 1
set :rails_env, "production"
set :migrate_target, :latest
role :web, "192.168.1.1"
role :app, "192.168.1.1"
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, roles: :app, except: { no_release: true } do
run "sudo touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
# Add this to add the `deploy:ping` task:
namespace :deploy do
task :ping do
system "curl --silent #{fetch(:ping_url)}"
end
end
namespace :gems do
task :bundle, :roles => :app do
run "cd #{release_path} && bundle install --without development && rake db:migrate RAILS_ENV=production"
end
end
after "deploy:update_code", "gems:bundle"
# Add this to automatically ping the server after a restart:
after "deploy:restart", "deploy:ping"
运行cap deploy:setup
和cap deploy:check
时,所有内容都恢复绿色点亮(工作正常).
When running a cap deploy:setup
and cap deploy:check
everything comes back green-lighted (working fine).
在实际的cap deploy
命令上失败.
** [192.168.1.1 :: out] Enter passphrase for key '/home/sergiotapia/.ssh/id_rsa':
Password:
** [192.168.1.1 :: out]
** [192.168.1.1 :: out] Permission denied (publickey).
** [192.168.1.1 :: out]
** [192.168.1.1 :: out] fatal: Could not read from remote repository.
** [192.168.1.1 :: out]
** [192.168.1.1 :: out]
** [192.168.1.1 :: out] Please make sure you have the correct access rights
** [192.168.1.1 :: out]
** [192.168.1.1 :: out] and the repository exists.
** [192.168.1.1 :: out]
我已经将我的id_rsa.pub
文件添加到BitBucket中,并且还确保使用ssh-add -l
命令将其添加到我的SSH代理中.
I've already added my id_rsa.pub
file to BitBucket and also made sure it's added to my SSH agent using the ssh-add -l
command.
即使从远程服务器上测试SSH也可以正常工作:
Even testing out SSH from the remote server works fine:
sergiotapia@tappia:~/www$ ssh -T git@bitbucket.org
logged in as sergiotapia.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
那有什么用,为什么拒绝我访问BitBucket上的存储库?
So what gives, why is denying me access to the repository on BitBucket?
Capistrano是否以sergiotapia
以外的用户身份运行?那是原因吗?
Is Capistrano running as a user other than sergiotapia
? Would that be the cause of it?
推荐答案
请确保将ssh密钥添加到身份验证代理:
Make sure to add your ssh key to the authentication agent:
ssh-add ~/.ssh/id_rsa
并确保在deploy.rb
and ensure in deploy.rb
ssh_options[:forward_agent] = true
如果重新启动时丢失了ssh-add配置,则应执行以下操作:
If you are losing the ssh-add configuration on reboots, you should do the following:
从macOS Sierra 10.12.2开始,Apple添加了一个名为UseKeychain的ssh_config选项,该选项可以适当"解决该问题.将以下内容添加到您的~/.ssh/config
文件中:
As of macOS Sierra 10.12.2 Apple added an ssh_config option called UseKeychain which allows a 'proper' resolution to the problem. Add the following to your ~/.ssh/config
file:
Host *
AddKeysToAgent yes
UseKeychain yes
这篇关于Capistrano bitbucket-权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!