ehs*_*nul 50 ruby capistrano ruby-on-rails sinatra ssh-keys
我的ssh密钥肯定设置正确,因为我在使用ssh时从未提示输入密码.但是在部署时,capistrano仍然要求输入密码cap deploy
.我设置的时候不会要求密码cap deploy:setup
,奇怪的是.如果没有密码提示,它将使部署周期更加顺畅.
细节:我正在将一个Sinatra应用程序部署到Dreamhost共享帐户(使用Passenger).我曾经按照教程做了很长时间,这在当时完美无缺.从那以后出现了什么.我正在使用capistrano(2.5.9)和git版本1.6.1.1.这是我的Capfile:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
set :user, 'ehsanul'
set :domain, 'jellly.com'
default_run_options[:pty] = true
# the rest should be good
set :repository, "ehsanul@jellly.com:git/jellly.git"
set :deploy_to, "/home/ehsanul/jellly.com"
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'deploy'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false
server domain, :app, :web
namespace :deploy do
task :migrate do
run "cd #{current_path}; /usr/bin/rake migrate environment=production"
end
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
after "deploy", "deploy:migrate"
Run Code Online (Sandbox Code Playgroud)
这是我cap deploy
在密码提示时发生的事情的输出:
$ cap deploy
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote ehsanul@jellly.com:git/jellly.git deploy"
/usr/local/bin/git
* executing "if [ -d /home/ehsanul/jellly.com/shared/cached-copy ]; then cd /home/ehsanul/jellly.com/shared/cached-copy && git fetch origin && git reset --hard ea744c77b0b939d5355ba2dc50ef1ec85f918d66 && git clean -d -x -f; else git clone --depth 1 ehsanul@jellly.com:git/jellly.git /home/ehsanul/jellly.com/shared/cached-copy && cd /home/ehsanul/jellly.com/shared/cached-copy && git checkout -b deploy ea744c77b0b939d5355ba2dc50ef1ec85f918d66; fi"
servers: ["jellly.com"]
[jellly.com] executing command
** [jellly.com :: out] ehsanul@jellly.com's password:
Password:
** [jellly.com :: out]
** [jellly.com :: out] remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
Run Code Online (Sandbox Code Playgroud)
什么可以打破?
Pab*_*lla 65
ssh-add ~/.ssh/id_rsa
在我的本地机器上执行为我修复了问题.当使用Capistrano调用时,似乎ssh命令行工具没有检测到我的身份.
tob*_*bym 54
密码提示是因为您要部署的服务器正在连接到git服务器并需要身份验证.由于您的本地计算机(您从中部署的位置)已经拥有有效的ssh-key,因此请在Capfile中启用转发来使用该计划:
set :ssh_options, {:forward_agent => true}
Run Code Online (Sandbox Code Playgroud)
当部署服务器尝试连接到您的git服务器时,它会从本地计算机转发身份验证.
这是将私钥放在部署服务器上的首选!
当服务器重新启动时,另一种绕过密码提示的方法是告诉capistrano不要这样做.感谢Daniel Quimper的capistrano-site5 github repo 的"自述"部分,我们注意到以下内容:
set :deploy_via, :copy
Run Code Online (Sandbox Code Playgroud)
显然,这适用于app和git存储库都托管在同一主机上的情况.但我想我们中的一些人正在这样做:)
fet*_*tsh 17
我遇到了同样的问题.
这条线没有用:
set :ssh_options, {:forward_agent => true}
Run Code Online (Sandbox Code Playgroud)
然后我在Dreamhost wiki上执行了提到
[local ~]$ eval `ssh-agent`
[local ~]$ ssh-add ~/.ssh/yourpublickey # omit path if using default keyname
Run Code Online (Sandbox Code Playgroud)
现在我可以无需密码即可部署.
归档时间: |
|
查看次数: |
38906 次 |
最近记录: |