cmw*_*cmw 8 ssh capistrano ruby-on-rails github linode
我继承了一个在Linode上托管的Rails项目.
之前的开发人员使用BitBucket存储库以及Capistrano进行部署.
我已经在GitHub上设置了一个私有存储库,我正试图让Capistrano配方工作.我没有运气.我在部署期间继续收到publickey错误.
以下是我采取的步骤 -
ssh_options[:forward_agent]设置为true在Capfilessh-add命令,以确保为auth代理添加了身份ssh -T git@github.com确认ssh在当地正确设置ssh -T git@github.com以确保它也正常工作另外,为了防止forward_agent属性不起作用,我甚至尝试在Linode服务器上生成SSH密钥,并将其添加到GitHub.没运气.
完成所有这些后,当我运行时cap deploy,我收到以下错误:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
以下是我正在使用的食谱 -
require "bundler/capistrano"
server "----SERVER IP----", :web, :app, :db, primary: true
set :application, "blog"
set :user, "deployer"
set :deploy_to, "/var/www/blog"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "git@github.com:--MY USERNAME--/blog.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
namespace :deploy do
task :start do; end
task :stop do; end
task :restart, roles: :app, except: {no_release: true} do
run "touch #{deploy_to}/current/tmp/restart.txt"
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/apache.conf /etc/apache2/sites-available/blog"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/public/avatars #{release_path}/public/avatars"
end
after "deploy:finalize_update", "deploy:symlink_config"
desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web 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
before "deploy", "deploy:check_revision"
end
Run Code Online (Sandbox Code Playgroud)
我似乎无法弄清楚我哪里出错了 - 任何帮助都会非常感激.
我还确保将以下内容添加到我的本地〜/ .ssh/config文件中...
Host mydomain.com
ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)
小智 20
今天我找到了MAC的根本原因.我的ssh密钥未添加到身份验证代理中,因此密钥未转发.解决方案是执行以下命令:
ssh-add~/.ssh/id_dsa
(或者如果你使用rsa键,则ssh-add~/.ssh/id_rsa)
Bil*_*tts 11
尝试将以下行添加到Capistrano脚本中,这将明确告诉Capistrano应该使用哪个键.
set :ssh_options, {
forward_agent: true,
paranoid: true,
keys: "~/.ssh/id_rsa"
}
Run Code Online (Sandbox Code Playgroud)