bin/tpkg in tpkg-2.1.0 vs bin/tpkg in tpkg-2.1.1
- old
+ new
@@ -380,13 +380,19 @@
if @deploy
# puts "Creating deployer with #{@worker_count} number of worker"
@deploy_options["max-worker"] = @worker_count
@deploy_options["abort-on-fail"] = false
- # check to see if ssh-key is accessible
- if @deploy_options["use-ssh-key"]
+ # Check to see if ssh-key is accessible
+ # Net::SSH doesn't warn the user about problems with the key file
+ # (i.e. if it doesn't exist or isn't readable), resulting in the user
+ # just getting a generic "Bad username/password combination" error
+ # message because authentication fails. As such we do some of our own
+ # checking and warning here so that the user gets a more specific
+ # error message.
+ if @deploy_options["use-ssh-key"] && @deploy_options["ssh-key"]
ssh_key = @deploy_options["ssh-key"]
- if !File.readable?(ssh_key) && Process.euid == 0
+ if !File.readable?(ssh_key) && (Process.euid == 0 || !@sudo)
raise "Unable to read ssh key from #{ssh_key}"
elsif !File.readable?(ssh_key)
warn "Warning: Unable to read ssh key from #{ssh_key}. Attempting to rerun tpkg with sudo."
rerun_with_sudo_if_necessary
end