我的ssh密鑰已經正確設置,因爲在使用ssh時從未提示輸入密碼。但是,當使用cap deploy
進行部署時,capistrano仍會要求輸入密碼。奇怪的是,當我使用cap deploy:setup
進行設置時,它並沒有要求輸入密碼。如果沒有密碼提示,它會使部署週期變得更加順暢。Capistrano在部署時要求輸入密碼,儘管使用SSH密鑰
細節:我將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, "[email protected]: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"
而這裏的情況如何輸出的時候我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 [email protected]: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 [email protected]: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] [email protected]'s password:
Password:
** [jellly.com :: out]
** [jellly.com :: out] remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
什麼可能被打破?
我沒有把我的私鑰放在服務器上。我只是將部署服務器的公鑰添加到它自己的'authorized_keys'列表中。這是因爲部署服務器也是我的git服務器,並且顯然它由於Capistrano的工作方式而嘗試進入ssh,導致密碼登錄。所以我基本上只是在服務器和它自己之間設置了ssh密鑰。比把我的私鑰放在那裏安全得多;) 雖然我會嘗試forward_agent的東西,看起來像一個更清潔的解決方案。謝謝! :) – ehsanul 2010-09-04 21:50:20
工作對我來說非常好。 – kain 2011-10-22 08:30:23
如果其他人想知道爲什麼會這樣工作,它在哪裏記錄,這些是Net:SSH的選項,請參閱http://net-ssh.github.com/ssh/v1/chapter-2.html中的「選項」。 – oseiskar 2013-02-16 13:16:24