net-ssh 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/lib/net/ssh/authentication/key_manager.rb +6 -7
- data/lib/net/ssh/authentication/methods/hostbased.rb +1 -1
- data/lib/net/ssh/authentication/methods/publickey.rb +1 -1
- data/lib/net/ssh/version.rb +1 -1
- data/net-ssh.gemspec +1 -1
- data/test/authentication/methods/test_hostbased.rb +6 -2
- data/test/authentication/methods/test_publickey.rb +6 -2
- data/test/authentication/test_key_manager.rb +9 -5
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
=== 2.0.8 / 29 December 2008
|
2
|
+
|
3
|
+
* Fix private key change from 2.0.7 so that keys are loaded just-in-time, avoiding unecessary prompts from encrypted keys. [Jamis Buck]
|
4
|
+
|
5
|
+
|
1
6
|
=== 2.0.7 / 29 December 2008
|
2
7
|
|
3
8
|
* Make key manager use private keys instead of requiring public key to exist [arilerner@mac.com]
|
@@ -74,17 +74,16 @@ module Net
|
|
74
74
|
@agent = nil
|
75
75
|
end
|
76
76
|
|
77
|
-
#
|
77
|
+
# Iterates over all available identities (public keys) known to this
|
78
|
+
# manager. As it finds one, it will then yield it to the caller.
|
78
79
|
# The origin of the identities may be from files on disk or from an
|
79
80
|
# ssh-agent. Note that identities from an ssh-agent are always listed
|
80
81
|
# first in the array, with other identities coming after.
|
81
|
-
def
|
82
|
-
identities = []
|
83
|
-
|
82
|
+
def each_identity
|
84
83
|
if agent
|
85
84
|
agent.identities.each do |key|
|
86
|
-
identities.push key
|
87
85
|
known_identities[key] = { :from => :agent }
|
86
|
+
yield key
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
@@ -93,15 +92,15 @@ module Net
|
|
93
92
|
begin
|
94
93
|
private_key = KeyFactory.load_private_key(file)
|
95
94
|
key = private_key.send :public_key
|
96
|
-
identities.push key
|
97
95
|
known_identities[key] = { :from => :file, :file => file }
|
96
|
+
yield key
|
98
97
|
rescue Exception => e
|
99
98
|
error { "could not load public key file `#{file}.pub': #{e.class} (#{e.message})" }
|
100
99
|
end
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
104
|
-
|
103
|
+
self
|
105
104
|
end
|
106
105
|
|
107
106
|
# Sign the given data, using the corresponding private key of the given
|
@@ -14,7 +14,7 @@ module Net
|
|
14
14
|
def authenticate(next_service, username, password=nil)
|
15
15
|
return false unless key_manager
|
16
16
|
|
17
|
-
key_manager.
|
17
|
+
key_manager.each_identity do |identity|
|
18
18
|
return true if authenticate_with(identity, next_service,
|
19
19
|
username, key_manager)
|
20
20
|
end
|
@@ -16,7 +16,7 @@ module Net
|
|
16
16
|
def authenticate(next_service, username, password=nil)
|
17
17
|
return false unless key_manager
|
18
18
|
|
19
|
-
key_manager.
|
19
|
+
key_manager.each_identity do |identity|
|
20
20
|
return true if authenticate_with(identity, next_service, username)
|
21
21
|
end
|
22
22
|
|
data/lib/net/ssh/version.rb
CHANGED
data/net-ssh.gemspec
CHANGED
@@ -79,7 +79,11 @@ module Authentication; module Methods
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def key_manager(options={})
|
82
|
-
@key_manager ||=
|
82
|
+
@key_manager ||= begin
|
83
|
+
manager = stub("key_manager")
|
84
|
+
manager.stubs(:each_identity).multiple_yields(*(options[:keys] || keys))
|
85
|
+
manager
|
86
|
+
end
|
83
87
|
end
|
84
88
|
|
85
89
|
def subject(options={})
|
@@ -107,4 +111,4 @@ module Authentication; module Methods
|
|
107
111
|
|
108
112
|
end
|
109
113
|
|
110
|
-
end; end
|
114
|
+
end; end
|
@@ -110,7 +110,11 @@ module Authentication; module Methods
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def key_manager(options={})
|
113
|
-
@key_manager ||=
|
113
|
+
@key_manager ||= begin
|
114
|
+
manager = stub("key_manager")
|
115
|
+
manager.stubs(:each_identity).multiple_yields(*(options[:keys] || keys))
|
116
|
+
manager
|
117
|
+
end
|
114
118
|
end
|
115
119
|
|
116
120
|
def subject(options={})
|
@@ -120,4 +124,4 @@ module Authentication; module Methods
|
|
120
124
|
|
121
125
|
end
|
122
126
|
|
123
|
-
end; end
|
127
|
+
end; end
|
@@ -28,13 +28,15 @@ module Authentication
|
|
28
28
|
assert !manager.use_agent?
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_each_identity_should_load_from_key_files
|
32
32
|
manager.stubs(:agent).returns(nil)
|
33
33
|
|
34
34
|
stub_file_key "/first", rsa
|
35
35
|
stub_file_key "/second", dsa
|
36
36
|
|
37
|
-
identities =
|
37
|
+
identities = []
|
38
|
+
manager.each_identity { |identity| identities << identity }
|
39
|
+
|
38
40
|
assert_equal 2, identities.length
|
39
41
|
assert_equal rsa.to_blob, identities.first.to_blob
|
40
42
|
assert_equal dsa.to_blob, identities.last.to_blob
|
@@ -45,7 +47,9 @@ module Authentication
|
|
45
47
|
|
46
48
|
def test_identities_should_load_from_agent
|
47
49
|
manager.stubs(:agent).returns(agent)
|
48
|
-
|
50
|
+
|
51
|
+
identities = []
|
52
|
+
manager.each_identity { |identity| identities << identity }
|
49
53
|
|
50
54
|
assert_equal 2, identities.length
|
51
55
|
assert_equal rsa.to_blob, identities.first.to_blob
|
@@ -57,7 +61,7 @@ module Authentication
|
|
57
61
|
|
58
62
|
def test_sign_with_agent_originated_key_should_request_signature_from_agent
|
59
63
|
manager.stubs(:agent).returns(agent)
|
60
|
-
manager.
|
64
|
+
manager.each_identity { |identity| } # preload the known_identities
|
61
65
|
agent.expects(:sign).with(rsa, "hello, world").returns("abcxyz123")
|
62
66
|
assert_equal "abcxyz123", manager.sign(rsa, "hello, world")
|
63
67
|
end
|
@@ -66,7 +70,7 @@ module Authentication
|
|
66
70
|
manager.stubs(:agent).returns(nil)
|
67
71
|
stub_file_key "/first", rsa(512), true
|
68
72
|
rsa.expects(:ssh_do_sign).with("hello, world").returns("abcxyz123")
|
69
|
-
manager.
|
73
|
+
manager.each_identity { |identity| } # preload the known_identities
|
70
74
|
assert_equal "\0\0\0\assh-rsa\0\0\0\011abcxyz123", manager.sign(rsa, "hello, world")
|
71
75
|
end
|
72
76
|
|