File: lenient-host-key-verifier.rb

package info (click to toggle)
libnet-ssh-ruby 1.1.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,472 kB
  • ctags: 2,465
  • sloc: ruby: 10,848; makefile: 17
file content (25 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'net/ssh/host-key-verifier'

module Net
  module SSH

    class LenientHostKeyVerifier < HostKeyVerifier
      def verify(arguments)
        return true if tunnelled?(arguments)
        super
      end

      private

        # A connection is potentially being tunnelled if the port is not 22,
        # and the ip refers to the localhost.
        def tunnelled?(args)
          return false if args[:peer][:port].to_i == 22
          
          ip = args[:peer][:ip]
          return ip == "127.0.0.1" || ip == "::1"
        end
    end

  end
end