嘗試從頭開始測試Capistrano。Capistrano 3丟棄:執行遠程SSH命令時的用戶變量
Capfile:
require 'capistrano/setup'
require 'capistrano/deploy'
I18n.enforce_available_locales = false
Dir.glob('lib/capistrano/tasks/*.rb').each { |r| import r }
deploy.rb:
role :testrole, 'x.x.x.x'
set :user, 'ubuntu'
的test.rb任務:
namespace :test do
desc "Uptime on servers"
task :uptime do
on roles(:testrole) do
execute "uptime"
end
end
end
帽命令:
cap production test:uptime
輸出:
INFO [c077da7f] Running /usr/bin/env uptime on x.x.x.x
DEBUG [c077da7f] Command: /usr/bin/env uptime
cap aborted!
Net::SSH::AuthenticationFailed
不必須使用相同的用戶和鍵殼登錄的問題。 當登錄到遠程服務器上,我可以看到auth.log一個空的用戶在執行上限給出:
test-srv sshd[1459]: Invalid user from x.x.x.x
我怎麼錯過? 謝謝!
P.S. 'env.fetch(:user)'裏面的任務顯示正確的用戶 – Bigmyx