Thanks, but it doesn't make any difference. That adds "-u root" to the
sudo command, but capistrano still seems to want to put in the root
password itself rather than prompting me to put it in.
I think I've found where it's doing it: in lib/capistrano/
configuration/actions/invocation.rb in the capistrano gem, I have:
def sudo(command, options={}, &block)
block ||= self.class.default_io_proc
options = options.dup
as = options.delete(:as)
user = as && "-u #{as}"
command = [fetch(:sudo, "sudo"), "-p '#{sudo_prompt}'",
user, command].compact.join(" ")
run(command, options, &sudo_behavior_callback(block))
end
def sudo_behavior_callback(fallback) #:nodoc:
# in order to prevent _each host_ from prompting when the
password
# was wrong, let's track which host prompted first and only
allow
# subsequent prompts from that host.
prompt_host = nil
Proc.new do |ch, stream, out|
if out =~ /^#{Regexp.escape(sudo_prompt)}/
ch.send_data "#{self[:password]}\n"
elsif out =~ /try again/
if prompt_host.nil? || prompt_host == ch[:server]
prompt_host = ch[:server]
logger.important out, "#{stream} :: #{ch[:server]}"
reset! :password
end
else
fallback.call(ch, stream, out)
end
end
end
This code appears to be putting in the password for the SSH user,
rather than prompting for the root password. Obviously I don't want to
have my server's root password sitting in a config file somewhere, so
I need this to prompt.
I think the issue is that sudo is set up on my server to want the
password of the target user, rather than that of the current user.
Thus I can run any command I want as root, as long as I know the root
password. Capistrano seems to be assuming that sudo wants the current
user's password rather than the target user's password.
R