def cp (froms, to, as: nil, quiet: false)
      as ||= @user
      output = ""
      synchronize do
        [froms].flatten.each do |from|
          if from.is_a?(String)
            to += "/" if to[-1] != "/" && from.is_a?(Array)
            command = ["rsync", "-e", ssh_command, "-r"]
            command += [*from, "#{as}@#{@address}:#{to}"]
            log.trace command.shelljoin, quiet: quiet
            IO.popen(command, in: :close, err: %i(child out)) do |io|
              until io.eof?
                begin
                  output << io.read_nonblock(100)
                rescue IO::WaitReadable
                  IO.select([io])
                  retry
                end
              end
              io.close
              if !$?.success?
                log.fatal "exit status #{$?.exitstatus}: #{command}", quiet: quiet
                log.fatal output, quiet: quiet
                fail "failed to copy files"
              end
            end
          elsif from.respond_to?(:read)
            cmd = "echo #{Base64.strict_encode64(from.read).shellescape} | base64 -d > #{to.shellescape}"
            sh cmd, quiet: quiet
          else
            fail "Don't know how to copy a #{from.class}: #{from}"
          end
        end
      end
      true
    end
def cp (froms, to, as: nil, quiet: false)
      as ||= @user
      output = ""
      synchronize do
        [froms].flatten.each do |from|
          if from.is_a?(String)
            to += "/" if to[-1] != "/" && from.is_a?(Array)
            command = ["rsync", "-e", ssh_command, "-r"]
            command += [*from, "#{as}@#{@address}:#{to}"]
            log.trace command.shelljoin, quiet: quiet
            IO.popen(command, in: :close, err: %i(child out)) do |io|
              until io.eof?
                begin
                  output << io.read_nonblock(100)
                rescue IO::WaitReadable
                  IO.select([io])
                  retry
                end
              end
              io.close
              if !$?.success?
                log.fatal "exit status #{$?.exitstatus}: #{command}", quiet: quiet
                log.fatal output, quiet: quiet
                fail "failed to copy files"
              end
            end
          elsif from.respond_to?(:read)
            cmd = "echo #{Base64.strict_encode64(from.read).shellescape} | base64 -d > #{to.shellescape}"
            sh cmd, quiet: quiet
          else
            fail "Don't know how to copy a #{from.class}: #{from}"
          end
        end
      end
      true
    end
Copy files or directories to the host.
 @api private