# File lib/net/ssh/config.rb, line 74
      def load(path, host, settings={})
        file = File.expand_path(path)
        return settings unless File.readable?(file)

        globals = {}
        matched_host = nil
        seen_host = false
        IO.foreach(file) do |line|
          next if line =~ /^\s*(?:#.*)?$/

          if line =~ /^\s*(\S+)\s*=(.*)$/
            key, value = $1, $2
          else
            key, value = line.strip.split(/\s+/, 2)
          end

          # silently ignore malformed entries
          next if value.nil?

          key.downcase!
          value = $1 if value =~ /^"(.*)"$/

          value = case value.strip
            when /^\d+$/ then value.to_i
            when /^no$/i then false
            when /^yes$/i then true
            else value
            end

          if key == 'host'
            # Support "Host host1 host2 hostN".
            # See http://github.com/net-ssh/net-ssh/issues#issue/6
            negative_hosts, positive_hosts = value.to_s.split(/\s+/).partition { |h| h.start_with?('!') }

            # Check for negative patterns first. If the host matches, that overrules any other positive match.
            # The host substring code is used to strip out the starting "!" so the regexp will be correct.
            negative_match = negative_hosts.select { |h| host =~ pattern2regex(h[1..-1]) }.first

            if negative_match
              matched_host = nil
            else
              matched_host = positive_hosts.select { |h| host =~ pattern2regex(h) }.first
            end

            seen_host = true
            settings[key] = host
          elsif !seen_host
            if key == 'identityfile'
              (globals[key] ||= []) << value
            else
              globals[key] = value unless settings.key?(key)
            end
          elsif !matched_host.nil?
            if key == 'identityfile'
              (settings[key] ||= []) << value
            else
              settings[key] = value unless settings.key?(key)
            end
          end
        end

        settings = globals.merge(settings) if globals

        return settings
      end