def configure_ssh_command(ip, command)
      use_sudo = ChefWorkflow::KnifeSupport.use_sudo
      command = "#{use_sudo ? 'sudo ': ''}#{command}"

      options = { }

      options[:password] = ChefWorkflow::KnifeSupport.ssh_password          if ChefWorkflow::KnifeSupport.ssh_password
      options[:keys]     = [ChefWorkflow::KnifeSupport.ssh_identity_file]   if ChefWorkflow::KnifeSupport.ssh_identity_file

      Net::SSH.start(ip, ChefWorkflow::KnifeSupport.ssh_user, options) do |ssh|
        ssh.open_channel do |ch|
          ch.request_pty do |ch, success|
            if !success and use_sudo
              raise "The use_sudo setting requires a PTY, and your SSH is rejecting our attempt to get one."
            end
          end

          ch.on_open_failed do |ch, code, desc|
            raise "Connection Error to #{ip}: #{desc}"
          end

          ch.exec(command) do |ch, success|
            yield ch, success
          end
        end

        ssh.loop
      end
    end
def configure_ssh_command(ip, command)
      use_sudo = ChefWorkflow::KnifeSupport.use_sudo
      command = "#{use_sudo ? 'sudo ': ''}#{command}"

      options = { }

      options[:password] = ChefWorkflow::KnifeSupport.ssh_password          if ChefWorkflow::KnifeSupport.ssh_password
      options[:keys]     = [ChefWorkflow::KnifeSupport.ssh_identity_file]   if ChefWorkflow::KnifeSupport.ssh_identity_file

      Net::SSH.start(ip, ChefWorkflow::KnifeSupport.ssh_user, options) do |ssh|
        ssh.open_channel do |ch|
          ch.request_pty do |ch, success|
            if !success and use_sudo
              raise "The use_sudo setting requires a PTY, and your SSH is rejecting our attempt to get one."
            end
          end

          ch.on_open_failed do |ch, code, desc|
            raise "Connection Error to #{ip}: #{desc}"
          end

          ch.exec(command) do |ch, success|
            yield ch, success
          end
        end

        ssh.loop
      end
    end
takes a block which it uses inside of the open_channel block that Net::SSH
 uses. Intended to provide a consistent way of setting up Net::SSH  Makes
 heavy use of KnifeSupport to determine how to drive the command.