net-ssh 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/Manifest +11 -0
- data/lib/net/ssh/transport/algorithms.rb +10 -8
- data/lib/net/ssh/transport/cipher_factory.rb +3 -21
- data/lib/net/ssh/transport/hmac.rb +14 -3
- data/lib/net/ssh/transport/hmac/sha2_256.rb +15 -0
- data/lib/net/ssh/transport/hmac/sha2_256_96.rb +13 -0
- data/lib/net/ssh/transport/hmac/sha2_512.rb +14 -0
- data/lib/net/ssh/transport/hmac/sha2_512_96.rb +13 -0
- data/lib/net/ssh/transport/kex.rb +6 -2
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +5 -2
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +15 -0
- data/lib/net/ssh/transport/key_expander.rb +26 -0
- data/lib/net/ssh/version.rb +2 -2
- data/net-ssh.gemspec +12 -5
- data/test/transport/hmac/test_sha2_256.rb +35 -0
- data/test/transport/hmac/test_sha2_256_96.rb +25 -0
- data/test/transport/hmac/test_sha2_512.rb +35 -0
- data/test/transport/hmac/test_sha2_512_96.rb +25 -0
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +2 -2
- data/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +33 -0
- data/test/transport/test_algorithms.rb +19 -13
- data/test/transport/test_hmac.rb +3 -3
- data/test/transport/test_packet_stream.rb +373 -85
- metadata +13 -6
- data/test/README.txt +0 -43
- data/test/configs/nohost +0 -19
- data/test/configs/numeric_host +0 -4
- data/test/manual/test_forward.rb +0 -223
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: net-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.
|
5
|
+
version: 2.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jamis Buck
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-01-
|
14
|
+
date: 2012-01-11 00:00:00 Z
|
15
15
|
dependencies: []
|
16
16
|
|
17
17
|
description: "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
|
@@ -82,10 +82,16 @@ files:
|
|
82
82
|
- lib/net/ssh/transport/hmac/none.rb
|
83
83
|
- lib/net/ssh/transport/hmac/sha1.rb
|
84
84
|
- lib/net/ssh/transport/hmac/sha1_96.rb
|
85
|
+
- lib/net/ssh/transport/hmac/sha2_256.rb
|
86
|
+
- lib/net/ssh/transport/hmac/sha2_256_96.rb
|
87
|
+
- lib/net/ssh/transport/hmac/sha2_512.rb
|
88
|
+
- lib/net/ssh/transport/hmac/sha2_512_96.rb
|
85
89
|
- lib/net/ssh/transport/identity_cipher.rb
|
90
|
+
- lib/net/ssh/transport/key_expander.rb
|
86
91
|
- lib/net/ssh/transport/kex.rb
|
87
92
|
- lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
|
88
93
|
- lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb
|
94
|
+
- lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb
|
89
95
|
- lib/net/ssh/transport/openssl.rb
|
90
96
|
- lib/net/ssh/transport/packet_stream.rb
|
91
97
|
- lib/net/ssh/transport/server_version.rb
|
@@ -99,7 +105,6 @@ files:
|
|
99
105
|
- setup.rb
|
100
106
|
- support/arcfour_check.rb
|
101
107
|
- support/ssh_tunnel_bug.rb
|
102
|
-
- test/README.txt
|
103
108
|
- test/authentication/methods/common.rb
|
104
109
|
- test/authentication/methods/test_abstract.rb
|
105
110
|
- test/authentication/methods/test_hostbased.rb
|
@@ -114,12 +119,9 @@ files:
|
|
114
119
|
- test/configs/exact_match
|
115
120
|
- test/configs/host_plus
|
116
121
|
- test/configs/multihost
|
117
|
-
- test/configs/nohost
|
118
|
-
- test/configs/numeric_host
|
119
122
|
- test/configs/wild_cards
|
120
123
|
- test/connection/test_channel.rb
|
121
124
|
- test/connection/test_session.rb
|
122
|
-
- test/manual/test_forward.rb
|
123
125
|
- test/test_all.rb
|
124
126
|
- test/test_buffer.rb
|
125
127
|
- test/test_buffered_io.rb
|
@@ -130,8 +132,13 @@ files:
|
|
130
132
|
- test/transport/hmac/test_none.rb
|
131
133
|
- test/transport/hmac/test_sha1.rb
|
132
134
|
- test/transport/hmac/test_sha1_96.rb
|
135
|
+
- test/transport/hmac/test_sha2_256.rb
|
136
|
+
- test/transport/hmac/test_sha2_256_96.rb
|
137
|
+
- test/transport/hmac/test_sha2_512.rb
|
138
|
+
- test/transport/hmac/test_sha2_512_96.rb
|
133
139
|
- test/transport/kex/test_diffie_hellman_group1_sha1.rb
|
134
140
|
- test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
|
141
|
+
- test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb
|
135
142
|
- test/transport/test_algorithms.rb
|
136
143
|
- test/transport/test_cipher_factory.rb
|
137
144
|
- test/transport/test_hmac.rb
|
data/test/README.txt
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
2011-01-19
|
2
|
-
|
3
|
-
RUNNING TESTS
|
4
|
-
|
5
|
-
Run the test suite from the net-ssh directory with the following command:
|
6
|
-
|
7
|
-
ruby -Ilib -Itest -rrubygems test/test_all.rb
|
8
|
-
|
9
|
-
Run a single test file like this:
|
10
|
-
|
11
|
-
ruby -Ilib -Itest -rrubygems test/transport/test_server_version.rb
|
12
|
-
|
13
|
-
|
14
|
-
EXPECTED RESULTS
|
15
|
-
|
16
|
-
* Ruby 1.8: all tests pass
|
17
|
-
|
18
|
-
* Ruby 1.9: all tests pass
|
19
|
-
|
20
|
-
* JRuby 1.5: 99% tests pass (448 tests, 1846 assertions, 1 failures)
|
21
|
-
|
22
|
-
|
23
|
-
PORT FORWARDING TESTS
|
24
|
-
|
25
|
-
ruby -Ilib -Itest -rrubygems test/manual/test_forward.rb
|
26
|
-
|
27
|
-
test_forward.rb must be run separately from the test suite because
|
28
|
-
it requires authorizing your public SSH keys on you localhost.
|
29
|
-
|
30
|
-
If you already have keys you can do this:
|
31
|
-
|
32
|
-
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
|
33
|
-
|
34
|
-
If you don't have keys see:
|
35
|
-
|
36
|
-
http://kimmo.suominen.com/docs/ssh/#ssh-keygen
|
37
|
-
|
38
|
-
You should now be able to login to your localhost with out
|
39
|
-
bring prompted for a password:
|
40
|
-
|
41
|
-
ssh localhost
|
42
|
-
|
43
|
-
-Delano
|
data/test/configs/nohost
DELETED
data/test/configs/numeric_host
DELETED
data/test/manual/test_forward.rb
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
# $ ruby -Ilib -Itest -rrubygems test/test_forward.rb
|
2
|
-
|
3
|
-
# Tests for the following patch:
|
4
|
-
#
|
5
|
-
# http://github.com/net-ssh/net-ssh/tree/portfwfix
|
6
|
-
#
|
7
|
-
# It fixes 3 issues, regarding closing forwarded ports:
|
8
|
-
#
|
9
|
-
# 1.) if client closes a forwarded connection, but the server is reading, net-ssh terminates with IOError socket closed.
|
10
|
-
# 2.) if client force closes (RST) a forwarded connection, but server is reading, net-ssh terminates with
|
11
|
-
# 3.) if server closes the sending side, the on_eof is not handled.
|
12
|
-
#
|
13
|
-
# More info:
|
14
|
-
#
|
15
|
-
# http://net-ssh.lighthouseapp.com/projects/36253/tickets/7
|
16
|
-
|
17
|
-
require 'common'
|
18
|
-
require 'net/ssh/buffer'
|
19
|
-
require 'net/ssh'
|
20
|
-
require 'timeout'
|
21
|
-
require 'tempfile'
|
22
|
-
|
23
|
-
class TestForward < Test::Unit::TestCase
|
24
|
-
|
25
|
-
def localhost
|
26
|
-
'localhost'
|
27
|
-
end
|
28
|
-
|
29
|
-
def ssh_start_params
|
30
|
-
[localhost ,ENV['USER']] #:verbose => :debug
|
31
|
-
end
|
32
|
-
|
33
|
-
def find_free_port
|
34
|
-
server = TCPServer.open(0)
|
35
|
-
server.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR,true)
|
36
|
-
port = server.addr[1]
|
37
|
-
server.close
|
38
|
-
port
|
39
|
-
end
|
40
|
-
|
41
|
-
def start_server_sending_lot_of_data(exceptions)
|
42
|
-
server = TCPServer.open(0)
|
43
|
-
Thread.start do
|
44
|
-
loop do
|
45
|
-
Thread.start(server.accept) do |client|
|
46
|
-
begin
|
47
|
-
10000.times do |i|
|
48
|
-
client.puts "item#{i}"
|
49
|
-
end
|
50
|
-
client.close
|
51
|
-
rescue
|
52
|
-
exceptions << $!
|
53
|
-
raise
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
return server
|
59
|
-
end
|
60
|
-
|
61
|
-
def start_server_closing_soon(exceptions=nil)
|
62
|
-
server = TCPServer.open(0)
|
63
|
-
Thread.start do
|
64
|
-
loop do
|
65
|
-
Thread.start(server.accept) do |client|
|
66
|
-
begin
|
67
|
-
client.recv(1024)
|
68
|
-
client.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, [1, 0].pack("ii"))
|
69
|
-
client.close
|
70
|
-
rescue
|
71
|
-
exceptions << $!
|
72
|
-
raise
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
return server
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_loop_should_not_abort_when_local_side_of_forward_is_closed
|
81
|
-
session = Net::SSH.start(*ssh_start_params)
|
82
|
-
server_exc = Queue.new
|
83
|
-
server = start_server_sending_lot_of_data(server_exc)
|
84
|
-
remote_port = server.addr[1]
|
85
|
-
local_port = find_free_port
|
86
|
-
session.forward.local(local_port, localhost, remote_port)
|
87
|
-
client_done = Queue.new
|
88
|
-
Thread.start do
|
89
|
-
begin
|
90
|
-
client = TCPSocket.new(localhost, local_port)
|
91
|
-
client.recv(1024)
|
92
|
-
client.close
|
93
|
-
sleep(0.2)
|
94
|
-
ensure
|
95
|
-
client_done << true
|
96
|
-
end
|
97
|
-
end
|
98
|
-
session.loop(0.1) { client_done.empty? }
|
99
|
-
assert_equal "Broken pipe", "#{server_exc.pop}" unless server_exc.empty?
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_loop_should_not_abort_when_local_side_of_forward_is_reset
|
103
|
-
session = Net::SSH.start(*ssh_start_params)
|
104
|
-
server_exc = Queue.new
|
105
|
-
server = start_server_sending_lot_of_data(server_exc)
|
106
|
-
remote_port = server.addr[1]
|
107
|
-
local_port = find_free_port
|
108
|
-
session.forward.local(local_port, localhost, remote_port)
|
109
|
-
client_done = Queue.new
|
110
|
-
Thread.start do
|
111
|
-
begin
|
112
|
-
client = TCPSocket.new(localhost, local_port)
|
113
|
-
client.recv(1024)
|
114
|
-
client.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, [1, 0].pack("ii"))
|
115
|
-
client.close
|
116
|
-
sleep(0.1)
|
117
|
-
ensure
|
118
|
-
client_done << true
|
119
|
-
end
|
120
|
-
end
|
121
|
-
session.loop(0.1) { client_done.empty? }
|
122
|
-
assert_equal "Broken pipe", "#{server_exc.pop}" unless server_exc.empty?
|
123
|
-
end
|
124
|
-
|
125
|
-
def create_local_socket(&blk)
|
126
|
-
tempfile = Tempfile.new("net_ssh_forward_test")
|
127
|
-
path = tempfile.path
|
128
|
-
tempfile.delete
|
129
|
-
yield UNIXServer.open(path)
|
130
|
-
File.delete(path)
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_forward_local_unix_socket_to_remote_port
|
134
|
-
session = Net::SSH.start(*ssh_start_params)
|
135
|
-
server_exc = Queue.new
|
136
|
-
server = start_server_sending_lot_of_data(server_exc)
|
137
|
-
remote_port = server.addr[1]
|
138
|
-
client_data = nil
|
139
|
-
|
140
|
-
create_local_socket do |local_socket|
|
141
|
-
session.forward.local(local_socket, localhost, remote_port)
|
142
|
-
client_done = Queue.new
|
143
|
-
|
144
|
-
Thread.start do
|
145
|
-
begin
|
146
|
-
client = UNIXSocket.new(local_socket.path)
|
147
|
-
client_data = client.recv(1024)
|
148
|
-
client.close
|
149
|
-
sleep(0.2)
|
150
|
-
ensure
|
151
|
-
client_done << true
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
session.loop(0.1) { client_done.empty? }
|
156
|
-
end
|
157
|
-
|
158
|
-
assert_not_nil(client_data, "client should have received data")
|
159
|
-
assert(client_data.match(/item\d/), 'client should have received the string item')
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_loop_should_not_abort_when_server_side_of_forward_is_closed
|
163
|
-
session = Net::SSH.start(*ssh_start_params)
|
164
|
-
server = start_server_closing_soon
|
165
|
-
remote_port = server.addr[1]
|
166
|
-
local_port = find_free_port
|
167
|
-
session.forward.local(local_port, localhost, remote_port)
|
168
|
-
client_done = Queue.new
|
169
|
-
Thread.start do
|
170
|
-
begin
|
171
|
-
client = TCPSocket.new(localhost, local_port)
|
172
|
-
1.times do |i|
|
173
|
-
client.puts "item#{i}"
|
174
|
-
end
|
175
|
-
client.close
|
176
|
-
sleep(0.1)
|
177
|
-
ensure
|
178
|
-
client_done << true
|
179
|
-
end
|
180
|
-
end
|
181
|
-
session.loop(0.1) { client_done.empty? }
|
182
|
-
end
|
183
|
-
|
184
|
-
def start_server
|
185
|
-
server = TCPServer.open(0)
|
186
|
-
Thread.start do
|
187
|
-
loop do
|
188
|
-
Thread.start(server.accept) do |client|
|
189
|
-
yield(client)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
return server
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_server_eof_should_be_handled
|
197
|
-
session = Net::SSH.start(*ssh_start_params)
|
198
|
-
server = start_server do |client|
|
199
|
-
client.write "This is a small message!"
|
200
|
-
client.close
|
201
|
-
end
|
202
|
-
client_done = Queue.new
|
203
|
-
client_exception = Queue.new
|
204
|
-
client_data = Queue.new
|
205
|
-
remote_port = server.addr[1]
|
206
|
-
local_port = find_free_port
|
207
|
-
session.forward.local(local_port, localhost, remote_port)
|
208
|
-
Thread.start do
|
209
|
-
begin
|
210
|
-
client = TCPSocket.new(localhost, local_port)
|
211
|
-
data = client.read(4096)
|
212
|
-
client.close
|
213
|
-
client_done << data
|
214
|
-
rescue
|
215
|
-
client_done << $!
|
216
|
-
end
|
217
|
-
end
|
218
|
-
timeout(5) do
|
219
|
-
session.loop(0.1) { client_done.empty? }
|
220
|
-
assert_equal "This is a small message!", client_done.pop
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|