net-ssh 5.0.0.beta1 → 5.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.rubocop_todo.yml +98 -258
  5. data/CHANGES.txt +8 -0
  6. data/Gemfile +1 -3
  7. data/Rakefile +37 -39
  8. data/lib/net/ssh.rb +26 -25
  9. data/lib/net/ssh/authentication/agent.rb +228 -225
  10. data/lib/net/ssh/authentication/certificate.rb +166 -164
  11. data/lib/net/ssh/authentication/constants.rb +17 -14
  12. data/lib/net/ssh/authentication/ed25519.rb +107 -104
  13. data/lib/net/ssh/authentication/ed25519_loader.rb +32 -28
  14. data/lib/net/ssh/authentication/key_manager.rb +5 -3
  15. data/lib/net/ssh/authentication/methods/abstract.rb +53 -47
  16. data/lib/net/ssh/authentication/methods/hostbased.rb +32 -33
  17. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +2 -4
  18. data/lib/net/ssh/authentication/methods/none.rb +10 -10
  19. data/lib/net/ssh/authentication/methods/password.rb +13 -13
  20. data/lib/net/ssh/authentication/methods/publickey.rb +54 -55
  21. data/lib/net/ssh/authentication/pageant.rb +468 -465
  22. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +44 -0
  23. data/lib/net/ssh/authentication/session.rb +127 -123
  24. data/lib/net/ssh/buffer.rb +305 -303
  25. data/lib/net/ssh/buffered_io.rb +163 -162
  26. data/lib/net/ssh/config.rb +230 -227
  27. data/lib/net/ssh/connection/channel.rb +659 -654
  28. data/lib/net/ssh/connection/constants.rb +30 -26
  29. data/lib/net/ssh/connection/event_loop.rb +108 -104
  30. data/lib/net/ssh/connection/keepalive.rb +54 -50
  31. data/lib/net/ssh/connection/session.rb +677 -678
  32. data/lib/net/ssh/connection/term.rb +180 -176
  33. data/lib/net/ssh/errors.rb +101 -99
  34. data/lib/net/ssh/key_factory.rb +108 -108
  35. data/lib/net/ssh/known_hosts.rb +148 -154
  36. data/lib/net/ssh/loggable.rb +56 -54
  37. data/lib/net/ssh/packet.rb +82 -78
  38. data/lib/net/ssh/prompt.rb +55 -53
  39. data/lib/net/ssh/proxy/command.rb +103 -102
  40. data/lib/net/ssh/proxy/errors.rb +12 -8
  41. data/lib/net/ssh/proxy/http.rb +92 -91
  42. data/lib/net/ssh/proxy/https.rb +42 -39
  43. data/lib/net/ssh/proxy/jump.rb +50 -47
  44. data/lib/net/ssh/proxy/socks4.rb +0 -2
  45. data/lib/net/ssh/proxy/socks5.rb +11 -11
  46. data/lib/net/ssh/ruby_compat.rb +1 -0
  47. data/lib/net/ssh/service/forward.rb +364 -362
  48. data/lib/net/ssh/test.rb +85 -83
  49. data/lib/net/ssh/test/channel.rb +146 -142
  50. data/lib/net/ssh/test/extensions.rb +148 -146
  51. data/lib/net/ssh/test/kex.rb +35 -31
  52. data/lib/net/ssh/test/local_packet.rb +48 -44
  53. data/lib/net/ssh/test/packet.rb +87 -84
  54. data/lib/net/ssh/test/remote_packet.rb +35 -31
  55. data/lib/net/ssh/test/script.rb +173 -171
  56. data/lib/net/ssh/test/socket.rb +59 -55
  57. data/lib/net/ssh/transport/algorithms.rb +413 -412
  58. data/lib/net/ssh/transport/cipher_factory.rb +108 -105
  59. data/lib/net/ssh/transport/constants.rb +35 -31
  60. data/lib/net/ssh/transport/ctr.rb +1 -1
  61. data/lib/net/ssh/transport/hmac.rb +1 -1
  62. data/lib/net/ssh/transport/hmac/abstract.rb +67 -64
  63. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +1 -1
  64. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +1 -1
  65. data/lib/net/ssh/transport/identity_cipher.rb +55 -51
  66. data/lib/net/ssh/transport/kex.rb +2 -4
  67. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +47 -40
  68. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +201 -197
  69. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -56
  70. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +94 -87
  71. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +17 -10
  72. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +17 -10
  73. data/lib/net/ssh/transport/key_expander.rb +29 -25
  74. data/lib/net/ssh/transport/openssl.rb +17 -30
  75. data/lib/net/ssh/transport/packet_stream.rb +193 -192
  76. data/lib/net/ssh/transport/server_version.rb +64 -66
  77. data/lib/net/ssh/transport/session.rb +286 -284
  78. data/lib/net/ssh/transport/state.rb +198 -196
  79. data/lib/net/ssh/verifiers/lenient.rb +29 -25
  80. data/lib/net/ssh/verifiers/null.rb +13 -9
  81. data/lib/net/ssh/verifiers/secure.rb +45 -45
  82. data/lib/net/ssh/verifiers/strict.rb +20 -16
  83. data/lib/net/ssh/version.rb +55 -53
  84. data/net-ssh.gemspec +4 -4
  85. data/support/ssh_tunnel_bug.rb +2 -2
  86. metadata +25 -24
  87. metadata.gz.sig +0 -0
@@ -1,12 +1,16 @@
1
- module Net; module SSH; module Verifiers
1
+ module Net
2
+ module SSH
3
+ module Verifiers
4
+
5
+ # The Null host key verifier simply allows every key it sees, without
6
+ # bothering to verify. This is simple, but is not particularly secure.
7
+ class Null
8
+ # Returns true.
9
+ def verify(arguments)
10
+ true
11
+ end
12
+ end
2
13
 
3
- # The Null host key verifier simply allows every key it sees, without
4
- # bothering to verify. This is simple, but is not particularly secure.
5
- class Null
6
- # Returns true.
7
- def verify(arguments)
8
- true
9
14
  end
10
15
  end
11
-
12
- end; end; end
16
+ end
@@ -1,52 +1,52 @@
1
1
  require 'net/ssh/errors'
2
2
  require 'net/ssh/known_hosts'
3
3
 
4
- module Net; module SSH; module Verifiers
5
-
6
- # Does a strict host verification, looking the server up in the known
7
- # host files to see if a key has already been seen for this server. If this
8
- # server does not appear in any host file, an exception will be raised
9
- # (HostKeyUnknown). This is in contrast to the "Strict" class, which will
10
- # silently add the key to your known_hosts file. If the server does appear at
11
- # least once, but the key given does not match any known for the server, an
12
- # exception will be raised (HostKeyMismatch).
13
- # Otherwise, this returns true.
14
- class Secure
15
- def verify(arguments)
16
- host_keys = arguments[:session].host_keys
17
-
18
- # We've never seen this host before, so raise an exception.
19
- if host_keys.empty?
20
- process_cache_miss(host_keys, arguments, HostKeyUnknown, "is unknown")
21
- end
22
-
23
- # If we found any matches, check to see that the key type and
24
- # blob also match.
25
- found = host_keys.any? do |key|
26
- key.ssh_type == arguments[:key].ssh_type &&
27
- key.to_blob == arguments[:key].to_blob
28
- end
29
-
30
- # If a match was found, return true. Otherwise, raise an exception
31
- # indicating that the key was not recognized.
32
- unless found
33
- process_cache_miss(host_keys, arguments, HostKeyMismatch, "does not match")
4
+ module Net
5
+ module SSH
6
+ module Verifiers
7
+
8
+ # Does a strict host verification, looking the server up in the known
9
+ # host files to see if a key has already been seen for this server. If this
10
+ # server does not appear in any host file, an exception will be raised
11
+ # (HostKeyUnknown). This is in contrast to the "Strict" class, which will
12
+ # silently add the key to your known_hosts file. If the server does appear at
13
+ # least once, but the key given does not match any known for the server, an
14
+ # exception will be raised (HostKeyMismatch).
15
+ # Otherwise, this returns true.
16
+ class Secure
17
+ def verify(arguments)
18
+ host_keys = arguments[:session].host_keys
19
+
20
+ # We've never seen this host before, so raise an exception.
21
+ process_cache_miss(host_keys, arguments, HostKeyUnknown, "is unknown") if host_keys.empty?
22
+
23
+ # If we found any matches, check to see that the key type and
24
+ # blob also match.
25
+ found = host_keys.any? do |key|
26
+ key.ssh_type == arguments[:key].ssh_type &&
27
+ key.to_blob == arguments[:key].to_blob
28
+ end
29
+
30
+ # If a match was found, return true. Otherwise, raise an exception
31
+ # indicating that the key was not recognized.
32
+ process_cache_miss(host_keys, arguments, HostKeyMismatch, "does not match") unless found
33
+
34
+ found
35
+ end
36
+
37
+ private
38
+
39
+ def process_cache_miss(host_keys, args, exc_class, message)
40
+ exception = exc_class.new("fingerprint #{args[:fingerprint]} " +
41
+ "#{message} for #{host_keys.host.inspect}")
42
+ exception.data = args
43
+ exception.callback = Proc.new do
44
+ host_keys.add_host_key(args[:key])
45
+ end
46
+ raise exception
47
+ end
34
48
  end
35
49
 
36
- found
37
- end
38
-
39
- private
40
-
41
- def process_cache_miss(host_keys, args, exc_class, message)
42
- exception = exc_class.new("fingerprint #{args[:fingerprint]} " +
43
- "#{message} for #{host_keys.host.inspect}")
44
- exception.data = args
45
- exception.callback = Proc.new do
46
- host_keys.add_host_key(args[:key])
47
- end
48
- raise exception
49
50
  end
50
51
  end
51
-
52
- end; end; end
52
+ end
@@ -2,23 +2,27 @@ require 'net/ssh/errors'
2
2
  require 'net/ssh/known_hosts'
3
3
  require 'net/ssh/verifiers/secure'
4
4
 
5
- module Net; module SSH; module Verifiers
5
+ module Net
6
+ module SSH
7
+ module Verifiers
6
8
 
7
- # Does a strict host verification, looking the server up in the known
8
- # host files to see if a key has already been seen for this server. If this
9
- # server does not appear in any host file, this will silently add the
10
- # server. If the server does appear at least once, but the key given does
11
- # not match any known for the server, an exception will be raised (HostKeyMismatch).
12
- # Otherwise, this returns true.
13
- class Strict < Secure
14
- def verify(arguments)
15
- begin
16
- super
17
- rescue HostKeyUnknown => err
18
- err.remember_host!
19
- return true
9
+ # Does a strict host verification, looking the server up in the known
10
+ # host files to see if a key has already been seen for this server. If this
11
+ # server does not appear in any host file, this will silently add the
12
+ # server. If the server does appear at least once, but the key given does
13
+ # not match any known for the server, an exception will be raised (HostKeyMismatch).
14
+ # Otherwise, this returns true.
15
+ class Strict < Secure
16
+ def verify(arguments)
17
+ begin
18
+ super
19
+ rescue HostKeyUnknown => err
20
+ err.remember_host!
21
+ return true
22
+ end
23
+ end
20
24
  end
25
+
21
26
  end
22
27
  end
23
-
24
- end; end; end
28
+ end
@@ -1,66 +1,68 @@
1
- module Net; module SSH
2
- # A class for describing the current version of a library. The version
3
- # consists of three parts: the +major+ number, the +minor+ number, and the
4
- # +tiny+ (or +patch+) number.
5
- #
6
- # Two Version instances may be compared, so that you can test that a version
7
- # of a library is what you require:
8
- #
9
- # require 'net/ssh/version'
10
- #
11
- # if Net::SSH::Version::CURRENT < Net::SSH::Version[2,1,0]
12
- # abort "your software is too old!"
13
- # end
14
- class Version
15
- include Comparable
1
+ module Net
2
+ module SSH
3
+ # A class for describing the current version of a library. The version
4
+ # consists of three parts: the +major+ number, the +minor+ number, and the
5
+ # +tiny+ (or +patch+) number.
6
+ #
7
+ # Two Version instances may be compared, so that you can test that a version
8
+ # of a library is what you require:
9
+ #
10
+ # require 'net/ssh/version'
11
+ #
12
+ # if Net::SSH::Version::CURRENT < Net::SSH::Version[2,1,0]
13
+ # abort "your software is too old!"
14
+ # end
15
+ class Version
16
+ include Comparable
16
17
 
17
- # A convenience method for instantiating a new Version instance with the
18
- # given +major+, +minor+, and +tiny+ components.
19
- def self.[](major, minor, tiny, pre = nil)
20
- new(major, minor, tiny, pre)
21
- end
18
+ # A convenience method for instantiating a new Version instance with the
19
+ # given +major+, +minor+, and +tiny+ components.
20
+ def self.[](major, minor, tiny, pre = nil)
21
+ new(major, minor, tiny, pre)
22
+ end
22
23
 
23
- attr_reader :major, :minor, :tiny
24
+ attr_reader :major, :minor, :tiny
24
25
 
25
- # Create a new Version object with the given components.
26
- def initialize(major, minor, tiny, pre = nil)
27
- @major, @minor, @tiny, @pre = major, minor, tiny, pre
28
- end
26
+ # Create a new Version object with the given components.
27
+ def initialize(major, minor, tiny, pre = nil)
28
+ @major, @minor, @tiny, @pre = major, minor, tiny, pre
29
+ end
29
30
 
30
- # Compare this version to the given +version+ object.
31
- def <=>(version)
32
- to_i <=> version.to_i
33
- end
31
+ # Compare this version to the given +version+ object.
32
+ def <=>(version)
33
+ to_i <=> version.to_i
34
+ end
34
35
 
35
- # Converts this version object to a string, where each of the three
36
- # version components are joined by the '.' character. E.g., 2.0.0.
37
- def to_s
38
- @to_s ||= [@major, @minor, @tiny, @pre].compact.join(".")
39
- end
36
+ # Converts this version object to a string, where each of the three
37
+ # version components are joined by the '.' character. E.g., 2.0.0.
38
+ def to_s
39
+ @to_s ||= [@major, @minor, @tiny, @pre].compact.join(".")
40
+ end
40
41
 
41
- # Converts this version to a canonical integer that may be compared
42
- # against other version objects.
43
- def to_i
44
- @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
45
- end
42
+ # Converts this version to a canonical integer that may be compared
43
+ # against other version objects.
44
+ def to_i
45
+ @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
46
+ end
46
47
 
47
- # The major component of this version of the Net::SSH library
48
- MAJOR = 5
48
+ # The major component of this version of the Net::SSH library
49
+ MAJOR = 5
49
50
 
50
- # The minor component of this version of the Net::SSH library
51
- MINOR = 0
51
+ # The minor component of this version of the Net::SSH library
52
+ MINOR = 0
52
53
 
53
- # The tiny component of this version of the Net::SSH library
54
- TINY = 0
54
+ # The tiny component of this version of the Net::SSH library
55
+ TINY = 0
55
56
 
56
- # The prerelease component of this version of the Net::SSH library
57
- # nil allowed
58
- PRE = "beta1"
57
+ # The prerelease component of this version of the Net::SSH library
58
+ # nil allowed
59
+ PRE = "beta2"
59
60
 
60
- # The current version of the Net::SSH library as a Version instance
61
- CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)
61
+ # The current version of the Net::SSH library as a Version instance
62
+ CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)
62
63
 
63
- # The current version of the Net::SSH library as a String
64
- STRING = CURRENT.to_s
64
+ # The current version of the Net::SSH library as a String
65
+ STRING = CURRENT.to_s
66
+ end
65
67
  end
66
- end; end
68
+ end
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+
2
2
  require_relative 'lib/net/ssh/version'
3
3
 
4
4
  Gem::Specification.new do |spec|
@@ -29,14 +29,14 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  unless ENV['NET_SSH_NO_ED25519']
32
- spec.add_development_dependency("ed25519", "~> 1.2")
33
32
  spec.add_development_dependency("bcrypt_pbkdf", "~> 1.0") unless RUBY_PLATFORM == "java"
33
+ spec.add_development_dependency("ed25519", "~> 1.2")
34
34
  end
35
35
 
36
36
  spec.add_development_dependency "bundler", "~> 1.11"
37
37
 
38
- spec.add_development_dependency "rake", "~> 12.0"
39
38
  spec.add_development_dependency "minitest", "~> 5.10"
40
- spec.add_development_dependency "rubocop", "~> 0.47.0"
41
39
  spec.add_development_dependency "mocha", ">= 1.2.1"
40
+ spec.add_development_dependency "rake", "~> 12.0"
41
+ spec.add_development_dependency "rubocop", "~> 0.54.0"
42
42
  end
@@ -39,8 +39,8 @@ puts "Configure your browser proxy to localhost:#{LOCAL_PORT}"
39
39
  begin
40
40
  session = Net::SSH.start(host, user, password: pass)
41
41
  session.forward.local(LOCAL_PORT, host, PROXY_PORT)
42
- session.loop{true}
43
- rescue => e
42
+ session.loop {true}
43
+ rescue StandardError => e
44
44
  puts e.message
45
45
  puts e.backtrace
46
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta1
4
+ version: 5.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -32,36 +32,36 @@ cert_chain:
32
32
  ZFwoIuXKeDmTTpryd/vI7sdLXDuV6MbWOLGh6gXn9RDDXG1EqEXW0bjovATBMpdH
33
33
  9OGohJvAFzcvhDTWPwT6w3PG5B80pqb9j1hEAg==
34
34
  -----END CERTIFICATE-----
35
- date: 2018-03-11 00:00:00.000000000 Z
35
+ date: 2018-03-22 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
- name: ed25519
38
+ name: bcrypt_pbkdf
39
39
  requirement: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '1.2'
43
+ version: '1.0'
44
44
  type: :development
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '1.2'
50
+ version: '1.0'
51
51
  - !ruby/object:Gem::Dependency
52
- name: bcrypt_pbkdf
52
+ name: ed25519
53
53
  requirement: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '1.0'
57
+ version: '1.2'
58
58
  type: :development
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '1.0'
64
+ version: '1.2'
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: bundler
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -77,61 +77,61 @@ dependencies:
77
77
  - !ruby/object:Gem::Version
78
78
  version: '1.11'
79
79
  - !ruby/object:Gem::Dependency
80
- name: rake
80
+ name: minitest
81
81
  requirement: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: '12.0'
85
+ version: '5.10'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '12.0'
92
+ version: '5.10'
93
93
  - !ruby/object:Gem::Dependency
94
- name: minitest
94
+ name: mocha
95
95
  requirement: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: '5.10'
99
+ version: 1.2.1
100
100
  type: :development
101
101
  prerelease: false
102
102
  version_requirements: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - "~>"
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: '5.10'
106
+ version: 1.2.1
107
107
  - !ruby/object:Gem::Dependency
108
- name: rubocop
108
+ name: rake
109
109
  requirement: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: 0.47.0
113
+ version: '12.0'
114
114
  type: :development
115
115
  prerelease: false
116
116
  version_requirements: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - "~>"
119
119
  - !ruby/object:Gem::Version
120
- version: 0.47.0
120
+ version: '12.0'
121
121
  - !ruby/object:Gem::Dependency
122
- name: mocha
122
+ name: rubocop
123
123
  requirement: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ">="
125
+ - - "~>"
126
126
  - !ruby/object:Gem::Version
127
- version: 1.2.1
127
+ version: 0.54.0
128
128
  type: :development
129
129
  prerelease: false
130
130
  version_requirements: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - ">="
132
+ - - "~>"
133
133
  - !ruby/object:Gem::Version
134
- version: 1.2.1
134
+ version: 0.54.0
135
135
  description: 'Net::SSH: a pure-Ruby implementation of the SSH2 client protocol. It
136
136
  allows you to write programs that invoke and interact with processes on remote servers,
137
137
  via SSH2.'
@@ -172,6 +172,7 @@ files:
172
172
  - lib/net/ssh/authentication/methods/password.rb
173
173
  - lib/net/ssh/authentication/methods/publickey.rb
174
174
  - lib/net/ssh/authentication/pageant.rb
175
+ - lib/net/ssh/authentication/pub_key_fingerprint.rb
175
176
  - lib/net/ssh/authentication/session.rb
176
177
  - lib/net/ssh/buffer.rb
177
178
  - lib/net/ssh/buffered_io.rb