在3.0之前有一种方法可以做到这一点:
# ... set :MysqL_password,proc { Capistrano::CLI.password_prompt "Gimme remote database server password. Don't worry,I won't tell anyone: " } # ... namespace :db do desc 'Dump remote database' task :dump do run "MysqLdump -u #{MysqL_user} -p #{MysqL_database} > ~/#{MysqL_database}.sql" do |channel,stream,data| if data =~ /^Enter password:/ channel.send_data "#{MysqL_password}\n" end end end end
它会提示输入密码,在您键入时不会显示密码,并且在日志和输出中不会留下任何痕迹.
现在,从3.0开始,我找到了唯一的方法:
# ... namespace :db do desc 'Dump remote database' task :dump do ask :MysqL_password,nil on roles(:db) do execute "MysqLdump -u#{fetch :MysqL_user} -p#{fetch :MysqL_password} #{fetch :MysqL_database} > ~/#{fetch :MysqL_database}.sql" end end end
它完成工作,但到处显示密码.
有没有人在3.0中找到一种安全的密码提示方式?谢谢!