我使用capistrano來運行命令。我有基於ssh-key的認證,但每臺機器上都有不同的sudo密碼。Capistrano,sudo命令和多個密碼
我capfile看起來像這樣
default_run_options[:pty] = true
role :admin, "server1","server2","server3"
desc "myCommand"
task :mycommand, :roles=>:admin do
run "cd <workdir> && #{sudo} <command>"
end
當我運行此我得到下面的輸出:
* executing `myCommand'
* executing "cd <workdir> && sudo -p 'sudo password: ' <command>"
servers: ["server1", "server2", "server3"]
[server2] executing command
[server3] executing command
Password:
** [out :: server2]
** [out :: server3]
[server1] executing command
** [out :: server1]
** [out :: server3] CMD-OUTPUT
*** [out :: server2] Sorry, try again.
** [out :: server2] Sorry, try again.
Password:
** [out :: server2]
** [out :: server1]
** [out :: server2] CMD-OUTPUT
** [out :: server1]
** [out :: server1] Sorry, try again.
** [out :: server1] sudo: 3 incorrect password attempts
command finished in 14411ms
failed: "sh -c 'cd <workdir> && sudo -p '\\''sudo password: '\\'' <command>'" on server1
顯然Capistrano的假設我有同樣的passwort每個服務器上,這可能嗎?我該如何解決這個問題?
請參閱此問題的答案:http://stackoverflow.com/questions/8241639/multiple-server-deploy-asking-ssh-password-for-each-server – 2012-04-16 16:17:50
我已經有公鑰登錄設置,但我需要sudo。我能以某種方式「不平行」運行嗎? – 2012-04-16 17:17:20