auser-poolparty 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/cloud-bootstrap +1 -0
  3. data/bin/cloud-configure +1 -0
  4. data/bin/cloud-contract +1 -0
  5. data/bin/poolparty-setup +36 -0
  6. data/examples/vmware.rb +18 -0
  7. data/lib/cloud_providers/cloud_provider_instance.rb +1 -1
  8. data/lib/core/object.rb +2 -2
  9. data/lib/dependency_resolvers/chef.rb +2 -2
  10. data/lib/mixins/askable.rb +16 -7
  11. data/lib/poolparty/base.rb +9 -7
  12. data/lib/poolparty/cloud.rb +57 -2
  13. data/lib/poolparty/installer.rb +8 -4
  14. data/lib/poolparty/installers/ec2.rb +75 -5
  15. data/lib/poolparty/installers/vmware.rb +17 -5
  16. data/lib/poolparty/plugins/apache.rb +3 -2
  17. data/lib/poolparty/plugins/apache2/base.conf.erb +2 -2
  18. data/lib/poolparty/plugins/apache2/browser_fixes.conf.erb +1 -1
  19. data/lib/poolparty/plugins/apache2/passenger_site.rb +2 -2
  20. data/lib/poolparty/pool.rb +9 -2
  21. data/lib/poolparty/resource.rb +20 -7
  22. data/lib/poolparty/resources/directory.rb +5 -1
  23. data/lib/poolparty/resources/exec.rb +2 -2
  24. data/lib/poolparty/resources/file.rb +8 -2
  25. data/lib/poolparty/resources/gem_package.rb +2 -2
  26. data/lib/poolparty/resources/line.rb +23 -6
  27. data/lib/poolparty/resources/mount.rb +2 -2
  28. data/lib/poolparty/resources/package.rb +2 -2
  29. data/lib/poolparty/resources/service.rb +2 -2
  30. data/lib/poolparty/resources/user.rb +2 -2
  31. data/lib/poolparty.rb +2 -2
  32. data/test/lib/poolparty/base_test.rb +13 -0
  33. data/test/lib/poolparty/resources/line_test.rb +3 -3
  34. data/test/lib/poolparty/resources/service_test.rb +1 -1
  35. data/vendor/gems/net-ssh/CHANGELOG.rdoc +127 -0
  36. data/vendor/gems/net-ssh/Manifest +104 -0
  37. data/vendor/gems/net-ssh/README.rdoc +110 -0
  38. data/vendor/gems/net-ssh/Rakefile +26 -0
  39. data/vendor/gems/net-ssh/THANKS.rdoc +16 -0
  40. data/vendor/gems/net-ssh/lib/net/ssh/authentication/agent.rb +176 -0
  41. data/vendor/gems/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  42. data/vendor/gems/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  43. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  44. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  45. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  46. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  47. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  48. data/vendor/gems/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  49. data/vendor/gems/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  50. data/vendor/gems/net-ssh/lib/net/ssh/buffer.rb +340 -0
  51. data/vendor/gems/net-ssh/lib/net/ssh/buffered_io.rb +149 -0
  52. data/vendor/gems/net-ssh/lib/net/ssh/config.rb +181 -0
  53. data/vendor/gems/net-ssh/lib/net/ssh/connection/channel.rb +625 -0
  54. data/vendor/gems/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  55. data/vendor/gems/net-ssh/lib/net/ssh/connection/session.rb +596 -0
  56. data/vendor/gems/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  57. data/vendor/gems/net-ssh/lib/net/ssh/errors.rb +85 -0
  58. data/vendor/gems/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  59. data/vendor/gems/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  60. data/vendor/gems/net-ssh/lib/net/ssh/loggable.rb +61 -0
  61. data/vendor/gems/net-ssh/lib/net/ssh/packet.rb +102 -0
  62. data/vendor/gems/net-ssh/lib/net/ssh/prompt.rb +93 -0
  63. data/vendor/gems/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  64. data/vendor/gems/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  65. data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  66. data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks5.rb +129 -0
  67. data/vendor/gems/net-ssh/lib/net/ssh/ruby_compat.rb +7 -0
  68. data/vendor/gems/net-ssh/lib/net/ssh/service/forward.rb +267 -0
  69. data/vendor/gems/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  70. data/vendor/gems/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  71. data/vendor/gems/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  72. data/vendor/gems/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  73. data/vendor/gems/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  74. data/vendor/gems/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  75. data/vendor/gems/net-ssh/lib/net/ssh/test/script.rb +157 -0
  76. data/vendor/gems/net-ssh/lib/net/ssh/test/socket.rb +59 -0
  77. data/vendor/gems/net-ssh/lib/net/ssh/test.rb +89 -0
  78. data/vendor/gems/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  79. data/vendor/gems/net-ssh/lib/net/ssh/transport/cipher_factory.rb +80 -0
  80. data/vendor/gems/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  81. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +78 -0
  82. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  83. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  84. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  85. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  86. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  87. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  88. data/vendor/gems/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  89. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  90. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  91. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  92. data/vendor/gems/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  93. data/vendor/gems/net-ssh/lib/net/ssh/transport/packet_stream.rb +230 -0
  94. data/vendor/gems/net-ssh/lib/net/ssh/transport/server_version.rb +60 -0
  95. data/vendor/gems/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  96. data/vendor/gems/net-ssh/lib/net/ssh/transport/state.rb +201 -0
  97. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  98. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  99. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  100. data/vendor/gems/net-ssh/lib/net/ssh/version.rb +62 -0
  101. data/vendor/gems/net-ssh/lib/net/ssh.rb +215 -0
  102. data/vendor/gems/net-ssh/net-ssh.gemspec +33 -0
  103. data/vendor/gems/net-ssh/setup.rb +1585 -0
  104. data/vendor/gems/net-ssh/test/authentication/methods/common.rb +28 -0
  105. data/vendor/gems/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  106. data/vendor/gems/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  107. data/vendor/gems/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  108. data/vendor/gems/net-ssh/test/authentication/methods/test_password.rb +50 -0
  109. data/vendor/gems/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  110. data/vendor/gems/net-ssh/test/authentication/test_agent.rb +205 -0
  111. data/vendor/gems/net-ssh/test/authentication/test_key_manager.rb +105 -0
  112. data/vendor/gems/net-ssh/test/authentication/test_session.rb +93 -0
  113. data/vendor/gems/net-ssh/test/common.rb +106 -0
  114. data/vendor/gems/net-ssh/test/configs/eqsign +3 -0
  115. data/vendor/gems/net-ssh/test/configs/exact_match +8 -0
  116. data/vendor/gems/net-ssh/test/configs/wild_cards +14 -0
  117. data/vendor/gems/net-ssh/test/connection/test_channel.rb +452 -0
  118. data/vendor/gems/net-ssh/test/connection/test_session.rb +488 -0
  119. data/vendor/gems/net-ssh/test/test_all.rb +6 -0
  120. data/vendor/gems/net-ssh/test/test_buffer.rb +336 -0
  121. data/vendor/gems/net-ssh/test/test_buffered_io.rb +63 -0
  122. data/vendor/gems/net-ssh/test/test_config.rb +84 -0
  123. data/vendor/gems/net-ssh/test/test_key_factory.rb +67 -0
  124. data/vendor/gems/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  125. data/vendor/gems/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  126. data/vendor/gems/net-ssh/test/transport/hmac/test_none.rb +34 -0
  127. data/vendor/gems/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  128. data/vendor/gems/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  129. data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  130. data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  131. data/vendor/gems/net-ssh/test/transport/test_algorithms.rb +302 -0
  132. data/vendor/gems/net-ssh/test/transport/test_cipher_factory.rb +171 -0
  133. data/vendor/gems/net-ssh/test/transport/test_hmac.rb +34 -0
  134. data/vendor/gems/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  135. data/vendor/gems/net-ssh/test/transport/test_packet_stream.rb +435 -0
  136. data/vendor/gems/net-ssh/test/transport/test_server_version.rb +57 -0
  137. data/vendor/gems/net-ssh/test/transport/test_session.rb +315 -0
  138. data/vendor/gems/net-ssh/test/transport/test_state.rb +173 -0
  139. metadata +109 -4
  140. data/bin/install-poolparty +0 -20
@@ -0,0 +1,201 @@
1
+ require 'zlib'
2
+ require 'net/ssh/transport/cipher_factory'
3
+ require 'net/ssh/transport/hmac'
4
+
5
+ module Net; module SSH; module Transport
6
+
7
+ # Encapsulates state information about one end of an SSH connection. Such
8
+ # state includes the packet sequence number, the algorithms in use, how
9
+ # many packets and blocks have been processed since the last reset, and so
10
+ # forth. This class will never be instantiated directly, but is used as
11
+ # part of the internal state of the PacketStream module.
12
+ class State
13
+ # The socket object that owns this state object.
14
+ attr_reader :socket
15
+
16
+ # The next packet sequence number for this socket endpoint.
17
+ attr_reader :sequence_number
18
+
19
+ # The hmac algorithm in use for this endpoint.
20
+ attr_reader :hmac
21
+
22
+ # The compression algorithm in use for this endpoint.
23
+ attr_reader :compression
24
+
25
+ # The compression level to use when compressing data (or nil, for the default).
26
+ attr_reader :compression_level
27
+
28
+ # The number of packets processed since the last call to #reset!
29
+ attr_reader :packets
30
+
31
+ # The number of data blocks processed since the last call to #reset!
32
+ attr_reader :blocks
33
+
34
+ # The cipher algorithm in use for this socket endpoint.
35
+ attr_reader :cipher
36
+
37
+ # The role that this state plays (either :client or :server)
38
+ attr_reader :role
39
+
40
+ # The maximum number of packets that this endpoint wants to process before
41
+ # needing a rekey.
42
+ attr_accessor :max_packets
43
+
44
+ # The maximum number of blocks that this endpoint wants to process before
45
+ # needing a rekey.
46
+ attr_accessor :max_blocks
47
+
48
+ # The user-specified maximum number of bytes that this endpoint ought to
49
+ # process before needing a rekey.
50
+ attr_accessor :rekey_limit
51
+
52
+ # Creates a new state object, belonging to the given socket. Initializes
53
+ # the algorithms to "none".
54
+ def initialize(socket, role)
55
+ @socket = socket
56
+ @role = role
57
+ @sequence_number = @packets = @blocks = 0
58
+ @cipher = CipherFactory.get("none")
59
+ @hmac = HMAC.get("none")
60
+ @compression = nil
61
+ @compressor = @decompressor = nil
62
+ @next_iv = ""
63
+ end
64
+
65
+ # A convenience method for quickly setting multiple values in a single
66
+ # command.
67
+ def set(values)
68
+ values.each do |key, value|
69
+ instance_variable_set("@#{key}", value)
70
+ end
71
+ reset!
72
+ end
73
+
74
+ def update_cipher(data)
75
+ result = cipher.update(data)
76
+ update_next_iv(role == :client ? result : data)
77
+ return result
78
+ end
79
+
80
+ def final_cipher
81
+ result = cipher.final
82
+ update_next_iv(role == :client ? result : "", true)
83
+ return result
84
+ end
85
+
86
+ # Increments the counters. The sequence number is incremented (and remapped
87
+ # so it always fits in a 32-bit integer). The number of packets and blocks
88
+ # are also incremented.
89
+ def increment(packet_length)
90
+ @sequence_number = (@sequence_number + 1) & 0xFFFFFFFF
91
+ @packets += 1
92
+ @blocks += (packet_length + 4) / cipher.block_size
93
+ end
94
+
95
+ # The compressor object to use when compressing data. This takes into account
96
+ # the desired compression level.
97
+ def compressor
98
+ @compressor ||= Zlib::Deflate.new(compression_level || Zlib::DEFAULT_COMPRESSION)
99
+ end
100
+
101
+ # The decompressor object to use when decompressing data.
102
+ def decompressor
103
+ @decompressor ||= Zlib::Inflate.new(nil)
104
+ end
105
+
106
+ # Returns true if data compression/decompression is enabled. This will
107
+ # return true if :standard compression is selected, or if :delayed
108
+ # compression is selected and the :authenticated hint has been received
109
+ # by the socket.
110
+ def compression?
111
+ compression == :standard || (compression == :delayed && socket.hints[:authenticated])
112
+ end
113
+
114
+ # Compresses the data. If no compression is in effect, this will just return
115
+ # the data unmodified, otherwise it uses #compressor to compress the data.
116
+ def compress(data)
117
+ data = data.to_s
118
+ return data unless compression?
119
+ compressor.deflate(data, Zlib::SYNC_FLUSH)
120
+ end
121
+
122
+ # Deompresses the data. If no compression is in effect, this will just return
123
+ # the data unmodified, otherwise it uses #decompressor to decompress the data.
124
+ def decompress(data)
125
+ data = data.to_s
126
+ return data unless compression?
127
+ decompressor.inflate(data)
128
+ end
129
+
130
+ # Resets the counters on the state object, but leaves the sequence_number
131
+ # unchanged. It also sets defaults for and recomputes the max_packets and
132
+ # max_blocks values.
133
+ def reset!
134
+ @packets = @blocks = 0
135
+
136
+ @max_packets ||= 1 << 31
137
+
138
+ if max_blocks.nil?
139
+ # cargo-culted from openssh. the idea is that "the 2^(blocksize*2)
140
+ # limit is too expensive for 3DES, blowfish, etc., so enforce a 1GB
141
+ # limit for small blocksizes."
142
+
143
+ if cipher.block_size >= 16
144
+ @max_blocks = 1 << (cipher.block_size * 2)
145
+ else
146
+ @max_blocks = (1 << 30) / cipher.block_size
147
+ end
148
+
149
+ # if a limit on the # of bytes has been given, convert that into a
150
+ # minimum number of blocks processed.
151
+
152
+ if rekey_limit
153
+ @max_blocks = [@max_blocks, rekey_limit / cipher.block_size].min
154
+ end
155
+ end
156
+
157
+ cleanup
158
+ end
159
+
160
+ # Closes any the compressor and/or decompressor objects that have been
161
+ # instantiated.
162
+ def cleanup
163
+ if @compressor
164
+ @compressor.finish if !@compressor.finished?
165
+ @compressor.close
166
+ end
167
+
168
+ if @decompressor
169
+ # we call reset here so that we don't get warnings when we try to
170
+ # close the decompressor
171
+ @decompressor.reset
172
+ @decompressor.close
173
+ end
174
+
175
+ @compressor = @decompressor = nil
176
+ end
177
+
178
+ # Returns true if the number of packets processed exceeds the maximum
179
+ # number of packets, or if the number of blocks processed exceeds the
180
+ # maximum number of blocks.
181
+ def needs_rekey?
182
+ max_packets && packets > max_packets ||
183
+ max_blocks && blocks > max_blocks
184
+ end
185
+
186
+ private
187
+
188
+ def update_next_iv(data, reset=false)
189
+ @next_iv << data
190
+ @next_iv = @next_iv[-cipher.iv_len..-1]
191
+
192
+ if reset
193
+ cipher.reset
194
+ cipher.iv = @next_iv
195
+ end
196
+
197
+ return data
198
+ end
199
+ end
200
+
201
+ end; end; end
@@ -0,0 +1,30 @@
1
+ require 'net/ssh/verifiers/strict'
2
+
3
+ module Net; module SSH; module Verifiers
4
+
5
+ # Basically the same as the Strict verifier, but does not try to actually
6
+ # verify a connection if the server is the localhost and the port is a
7
+ # nonstandard port number. Those two conditions will typically mean the
8
+ # connection is being tunnelled through a forwarded port, so the known-hosts
9
+ # file will not be helpful (in general).
10
+ class Lenient < Strict
11
+ # Tries to determine if the connection is being tunnelled, and if so,
12
+ # returns true. Otherwise, performs the standard strict verification.
13
+ def verify(arguments)
14
+ return true if tunnelled?(arguments)
15
+ super
16
+ end
17
+
18
+ private
19
+
20
+ # A connection is potentially being tunnelled if the port is not 22,
21
+ # and the ip refers to the localhost.
22
+ def tunnelled?(args)
23
+ return false if args[:session].port == Net::SSH::Transport::Session::DEFAULT_PORT
24
+
25
+ ip = args[:session].peer[:ip]
26
+ return ip == "127.0.0.1" || ip == "::1"
27
+ end
28
+ end
29
+
30
+ end; end; end
@@ -0,0 +1,12 @@
1
+ module Net; module SSH; module Verifiers
2
+
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
+ end
10
+ end
11
+
12
+ end; end; end
@@ -0,0 +1,53 @@
1
+ require 'net/ssh/errors'
2
+ require 'net/ssh/known_hosts'
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, this will silently add the
9
+ # server. If the server does appear at least once, but the key given does
10
+ # not match any known for the server, an exception will be raised (HostKeyMismatch).
11
+ # Otherwise, this returns true.
12
+ class Strict
13
+ def verify(arguments)
14
+ options = arguments[:session].options
15
+ host = options[:host_key_alias] || arguments[:session].host_as_string
16
+ matches = Net::SSH::KnownHosts.search_for(host, arguments[:session].options)
17
+
18
+ # we've never seen this host before, so just automatically add the key.
19
+ # not the most secure option (since the first hit might be the one that
20
+ # is hacked), but since almost nobody actually compares the key
21
+ # fingerprint, this is a reasonable compromise between usability and
22
+ # security.
23
+ if matches.empty?
24
+ ip = arguments[:session].peer[:ip]
25
+ Net::SSH::KnownHosts.add(host, arguments[:key], arguments[:session].options)
26
+ return true
27
+ end
28
+
29
+ # If we found any matches, check to see that the key type and
30
+ # blob also match.
31
+ found = matches.any? do |key|
32
+ key.ssh_type == arguments[:key].ssh_type &&
33
+ key.to_blob == arguments[:key].to_blob
34
+ end
35
+
36
+ # If a match was found, return true. Otherwise, raise an exception
37
+ # indicating that the key was not recognized.
38
+ found || process_cache_miss(host, arguments)
39
+ end
40
+
41
+ private
42
+
43
+ def process_cache_miss(host, args)
44
+ exception = HostKeyMismatch.new("fingerprint #{args[:fingerprint]} does not match for #{host.inspect}")
45
+ exception.data = args
46
+ exception.callback = Proc.new do
47
+ Net::SSH::KnownHosts.add(host, args[:key], args[:session].options)
48
+ end
49
+ raise exception
50
+ end
51
+ end
52
+
53
+ end; end; end
@@ -0,0 +1,62 @@
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
16
+
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)
20
+ new(major, minor, tiny)
21
+ end
22
+
23
+ attr_reader :major, :minor, :tiny
24
+
25
+ # Create a new Version object with the given components.
26
+ def initialize(major, minor, tiny)
27
+ @major, @minor, @tiny = major, minor, tiny
28
+ end
29
+
30
+ # Compare this version to the given +version+ object.
31
+ def <=>(version)
32
+ to_i <=> version.to_i
33
+ end
34
+
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].join(".")
39
+ end
40
+
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
46
+
47
+ # The major component of this version of the Net::SSH library
48
+ MAJOR = 2
49
+
50
+ # The minor component of this version of the Net::SSH library
51
+ MINOR = 0
52
+
53
+ # The tiny component of this version of the Net::SSH library
54
+ TINY = 11
55
+
56
+ # The current version of the Net::SSH library as a Version instance
57
+ CURRENT = new(MAJOR, MINOR, TINY)
58
+
59
+ # The current version of the Net::SSH library as a String
60
+ STRING = CURRENT.to_s
61
+ end
62
+ end; end
@@ -0,0 +1,215 @@
1
+ # Make sure HOME is set, regardless of OS, so that File.expand_path works
2
+ # as expected with tilde characters.
3
+ ENV['HOME'] ||= ENV['HOMEPATH'] ? "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" : "."
4
+
5
+ require 'logger'
6
+
7
+ require 'net/ssh/config'
8
+ require 'net/ssh/errors'
9
+ require 'net/ssh/loggable'
10
+ require 'net/ssh/transport/session'
11
+ require 'net/ssh/authentication/session'
12
+ require 'net/ssh/connection/session'
13
+
14
+ module Net
15
+
16
+ # Net::SSH is a library for interacting, programmatically, with remote
17
+ # processes via the SSH2 protocol. Sessions are always initiated via
18
+ # Net::SSH.start. From there, a program interacts with the new SSH session
19
+ # via the convenience methods on Net::SSH::Connection::Session, by opening
20
+ # and interacting with new channels (Net::SSH::Connection:Session#open_channel
21
+ # and Net::SSH::Connection::Channel), or by forwarding local and/or
22
+ # remote ports through the connection (Net::SSH::Service::Forward).
23
+ #
24
+ # The SSH protocol is very event-oriented. Requests are sent from the client
25
+ # to the server, and are answered asynchronously. This gives great flexibility
26
+ # (since clients can have multiple requests pending at a time), but it also
27
+ # adds complexity. Net::SSH tries to manage this complexity by providing
28
+ # some simpler methods of synchronous communication (see Net::SSH::Connection::Session#exec!).
29
+ #
30
+ # In general, though, and if you want to do anything more complicated than
31
+ # simply executing commands and capturing their output, you'll need to use
32
+ # channels (Net::SSH::Connection::Channel) to build state machines that are
33
+ # executed while the event loop runs (Net::SSH::Connection::Session#loop).
34
+ #
35
+ # Net::SSH::Connection::Session and Net::SSH::Connection::Channel have more
36
+ # information about this technique.
37
+ #
38
+ # = "Um, all I want to do is X, just show me how!"
39
+ #
40
+ # == X == "execute a command and capture the output"
41
+ #
42
+ # Net::SSH.start("host", "user", :password => "password") do |ssh|
43
+ # result = ssh.exec!("ls -l")
44
+ # puts result
45
+ # end
46
+ #
47
+ # == X == "forward connections on a local port to a remote host"
48
+ #
49
+ # Net::SSH.start("host", "user", :password => "password") do |ssh|
50
+ # ssh.forward.local(1234, "www.google.com", 80)
51
+ # ssh.loop { true }
52
+ # end
53
+ #
54
+ # == X == "forward connections on a remote port to the local host"
55
+ #
56
+ # Net::SSH.start("host", "user", :password => "password") do |ssh|
57
+ # ssh.forward.remote(80, "www.google.com", 1234)
58
+ # ssh.loop { true }
59
+ # end
60
+ module SSH
61
+ # This is the set of options that Net::SSH.start recognizes. See
62
+ # Net::SSH.start for a description of each option.
63
+ VALID_OPTIONS = [
64
+ :auth_methods, :compression, :compression_level, :config, :encryption,
65
+ :forward_agent, :hmac, :host_key, :kex, :keys, :key_data, :languages,
66
+ :logger, :paranoid, :password, :port, :proxy, :rekey_blocks_limit,
67
+ :rekey_limit, :rekey_packet_limit, :timeout, :verbose,
68
+ :global_known_hosts_file, :user_known_hosts_file, :host_key_alias,
69
+ :host_name, :user, :properties, :passphrase
70
+ ]
71
+
72
+ # The standard means of starting a new SSH connection. When used with a
73
+ # block, the connection will be closed when the block terminates, otherwise
74
+ # the connection will just be returned. The yielded (or returned) value
75
+ # will be an instance of Net::SSH::Connection::Session (q.v.). (See also
76
+ # Net::SSH::Connection::Channel and Net::SSH::Service::Forward.)
77
+ #
78
+ # Net::SSH.start("host", "user") do |ssh|
79
+ # ssh.exec! "cp /some/file /another/location"
80
+ # hostname = ssh.exec!("hostname")
81
+ #
82
+ # ssh.open_channel do |ch|
83
+ # ch.exec "sudo -p 'sudo password: ' ls" do |ch, success|
84
+ # abort "could not execute sudo ls" unless success
85
+ #
86
+ # ch.on_data do |ch, data|
87
+ # print data
88
+ # if data =~ /sudo password: /
89
+ # ch.send_data("password\n")
90
+ # end
91
+ # end
92
+ # end
93
+ # end
94
+ #
95
+ # ssh.loop
96
+ # end
97
+ #
98
+ # This method accepts the following options (all are optional):
99
+ #
100
+ # * :auth_methods => an array of authentication methods to try
101
+ # * :compression => the compression algorithm to use, or +true+ to use
102
+ # whatever is supported.
103
+ # * :compression_level => the compression level to use when sending data
104
+ # * :config => set to +true+ to load the default OpenSSH config files
105
+ # (~/.ssh/config, /etc/ssh_config), or to +false+ to not load them, or to
106
+ # a file-name (or array of file-names) to load those specific configuration
107
+ # files. Defaults to +true+.
108
+ # * :encryption => the encryption cipher (or ciphers) to use
109
+ # * :forward_agent => set to true if you want the SSH agent connection to
110
+ # be forwarded
111
+ # * :global_known_hosts_file => the location of the global known hosts
112
+ # file. Set to an array if you want to specify multiple global known
113
+ # hosts files. Defaults to %w(/etc/ssh/known_hosts /etc/ssh/known_hosts2).
114
+ # * :hmac => the hmac algorithm (or algorithms) to use
115
+ # * :host_key => the host key algorithm (or algorithms) to use
116
+ # * :host_key_alias => the host name to use when looking up or adding a
117
+ # host to a known_hosts dictionary file
118
+ # * :host_name => the real host name or IP to log into. This is used
119
+ # instead of the +host+ parameter, and is primarily only useful when
120
+ # specified in an SSH configuration file. It lets you specify an
121
+ # "alias", similarly to adding an entry in /etc/hosts but without needing
122
+ # to modify /etc/hosts.
123
+ # * :kex => the key exchange algorithm (or algorithms) to use
124
+ # * :keys => an array of file names of private keys to use for publickey
125
+ # and hostbased authentication
126
+ # * :key_data => an array of strings, with each element of the array being
127
+ # a raw private key in PEM format.
128
+ # * :logger => the logger instance to use when logging
129
+ # * :paranoid => either true, false, or :very, specifying how strict
130
+ # host-key verification should be
131
+ # * :passphrase => the passphrase to use when loading a private key (default
132
+ # is +nil+, for no passphrase)
133
+ # * :password => the password to use to login
134
+ # * :port => the port to use when connecting to the remote host
135
+ # * :properties => a hash of key/value pairs to add to the new connection's
136
+ # properties (see Net::SSH::Connection::Session#properties)
137
+ # * :proxy => a proxy instance (see Proxy) to use when connecting
138
+ # * :rekey_blocks_limit => the max number of blocks to process before rekeying
139
+ # * :rekey_limit => the max number of bytes to process before rekeying
140
+ # * :rekey_packet_limit => the max number of packets to process before rekeying
141
+ # * :timeout => how long to wait for the initial connection to be made
142
+ # * :user => the user name to log in as; this overrides the +user+
143
+ # parameter, and is primarily only useful when provided via an SSH
144
+ # configuration file.
145
+ # * :user_known_hosts_file => the location of the user known hosts file.
146
+ # Set to an array to specify multiple user known hosts files.
147
+ # Defaults to %w(~/.ssh/known_hosts ~/.ssh/known_hosts2).
148
+ # * :verbose => how verbose to be (Logger verbosity constants, Logger::DEBUG
149
+ # is very verbose, Logger::FATAL is all but silent). Logger::FATAL is the
150
+ # default. The symbols :debug, :info, :warn, :error, and :fatal are also
151
+ # supported and are translated to the corresponding Logger constant.
152
+ def self.start(host, user, options={}, &block)
153
+ invalid_options = options.keys - VALID_OPTIONS
154
+ if invalid_options.any?
155
+ raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}"
156
+ end
157
+
158
+ options[:user] = user if user
159
+ options = configuration_for(host, options.fetch(:config, true)).merge(options)
160
+ host = options.fetch(:host_name, host)
161
+
162
+ if !options.key?(:logger)
163
+ options[:logger] = Logger.new(STDERR)
164
+ options[:logger].level = Logger::FATAL
165
+ end
166
+
167
+ if options[:verbose]
168
+ options[:logger].level = case options[:verbose]
169
+ when Fixnum then options[:verbose]
170
+ when :debug then Logger::DEBUG
171
+ when :info then Logger::INFO
172
+ when :warn then Logger::WARN
173
+ when :error then Logger::ERROR
174
+ when :fatal then Logger::FATAL
175
+ else raise ArgumentError, "can't convert #{options[:verbose].inspect} to any of the Logger level constants"
176
+ end
177
+ end
178
+
179
+ transport = Transport::Session.new(host, options)
180
+ auth = Authentication::Session.new(transport, options)
181
+
182
+ user = options.fetch(:user, user)
183
+ if auth.authenticate("ssh-connection", user, options[:password])
184
+ connection = Connection::Session.new(transport, options)
185
+ if block_given?
186
+ yield connection
187
+ connection.close
188
+ else
189
+ return connection
190
+ end
191
+ else
192
+ raise AuthenticationFailed, user
193
+ end
194
+ end
195
+
196
+ # Returns a hash of the configuration options for the given host, as read
197
+ # from the SSH configuration file(s). If +use_ssh_config+ is true (the
198
+ # default), this will load configuration from both ~/.ssh/config and
199
+ # /etc/ssh_config. If +use_ssh_config+ is nil or false, nothing will be
200
+ # loaded (and an empty hash returned). Otherwise, +use_ssh_config+ may
201
+ # be a file name (or array of file names) of SSH configuration file(s)
202
+ # to read.
203
+ #
204
+ # See Net::SSH::Config for the full description of all supported options.
205
+ def self.configuration_for(host, use_ssh_config=true)
206
+ files = case use_ssh_config
207
+ when true then Net::SSH::Config.default_files
208
+ when false, nil then return {}
209
+ else Array(use_ssh_config)
210
+ end
211
+
212
+ Net::SSH::Config.for(host, files)
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,33 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{net-ssh}
3
+ s.version = "2.0.11"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Jamis Buck"]
7
+ s.date = %q{2009-02-24}
8
+ s.description = %q{a pure-Ruby implementation of the SSH2 client protocol}
9
+ s.email = %q{jamis@jamisbuck.org}
10
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/ssh/authentication/agent.rb", "lib/net/ssh/authentication/constants.rb", "lib/net/ssh/authentication/key_manager.rb", "lib/net/ssh/authentication/methods/abstract.rb", "lib/net/ssh/authentication/methods/hostbased.rb", "lib/net/ssh/authentication/methods/keyboard_interactive.rb", "lib/net/ssh/authentication/methods/password.rb", "lib/net/ssh/authentication/methods/publickey.rb", "lib/net/ssh/authentication/pageant.rb", "lib/net/ssh/authentication/session.rb", "lib/net/ssh/buffer.rb", "lib/net/ssh/buffered_io.rb", "lib/net/ssh/config.rb", "lib/net/ssh/connection/channel.rb", "lib/net/ssh/connection/constants.rb", "lib/net/ssh/connection/session.rb", "lib/net/ssh/connection/term.rb", "lib/net/ssh/errors.rb", "lib/net/ssh/key_factory.rb", "lib/net/ssh/known_hosts.rb", "lib/net/ssh/loggable.rb", "lib/net/ssh/packet.rb", "lib/net/ssh/prompt.rb", "lib/net/ssh/proxy/errors.rb", "lib/net/ssh/proxy/http.rb", "lib/net/ssh/proxy/socks4.rb", "lib/net/ssh/proxy/socks5.rb", "lib/net/ssh/ruby_compat.rb", "lib/net/ssh/service/forward.rb", "lib/net/ssh/test/channel.rb", "lib/net/ssh/test/extensions.rb", "lib/net/ssh/test/kex.rb", "lib/net/ssh/test/local_packet.rb", "lib/net/ssh/test/packet.rb", "lib/net/ssh/test/remote_packet.rb", "lib/net/ssh/test/script.rb", "lib/net/ssh/test/socket.rb", "lib/net/ssh/test.rb", "lib/net/ssh/transport/algorithms.rb", "lib/net/ssh/transport/cipher_factory.rb", "lib/net/ssh/transport/constants.rb", "lib/net/ssh/transport/hmac/abstract.rb", "lib/net/ssh/transport/hmac/md5.rb", "lib/net/ssh/transport/hmac/md5_96.rb", "lib/net/ssh/transport/hmac/none.rb", "lib/net/ssh/transport/hmac/sha1.rb", "lib/net/ssh/transport/hmac/sha1_96.rb", "lib/net/ssh/transport/hmac.rb", "lib/net/ssh/transport/identity_cipher.rb", "lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb", "lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb", "lib/net/ssh/transport/kex.rb", "lib/net/ssh/transport/openssl.rb", "lib/net/ssh/transport/packet_stream.rb", "lib/net/ssh/transport/server_version.rb", "lib/net/ssh/transport/session.rb", "lib/net/ssh/transport/state.rb", "lib/net/ssh/verifiers/lenient.rb", "lib/net/ssh/verifiers/null.rb", "lib/net/ssh/verifiers/strict.rb", "lib/net/ssh/version.rb", "lib/net/ssh.rb", "README.rdoc", "THANKS.rdoc"]
11
+ s.files = ["CHANGELOG.rdoc", "lib/net/ssh/authentication/agent.rb", "lib/net/ssh/authentication/constants.rb", "lib/net/ssh/authentication/key_manager.rb", "lib/net/ssh/authentication/methods/abstract.rb", "lib/net/ssh/authentication/methods/hostbased.rb", "lib/net/ssh/authentication/methods/keyboard_interactive.rb", "lib/net/ssh/authentication/methods/password.rb", "lib/net/ssh/authentication/methods/publickey.rb", "lib/net/ssh/authentication/pageant.rb", "lib/net/ssh/authentication/session.rb", "lib/net/ssh/buffer.rb", "lib/net/ssh/buffered_io.rb", "lib/net/ssh/config.rb", "lib/net/ssh/connection/channel.rb", "lib/net/ssh/connection/constants.rb", "lib/net/ssh/connection/session.rb", "lib/net/ssh/connection/term.rb", "lib/net/ssh/errors.rb", "lib/net/ssh/key_factory.rb", "lib/net/ssh/known_hosts.rb", "lib/net/ssh/loggable.rb", "lib/net/ssh/packet.rb", "lib/net/ssh/prompt.rb", "lib/net/ssh/proxy/errors.rb", "lib/net/ssh/proxy/http.rb", "lib/net/ssh/proxy/socks4.rb", "lib/net/ssh/proxy/socks5.rb", "lib/net/ssh/ruby_compat.rb", "lib/net/ssh/service/forward.rb", "lib/net/ssh/test/channel.rb", "lib/net/ssh/test/extensions.rb", "lib/net/ssh/test/kex.rb", "lib/net/ssh/test/local_packet.rb", "lib/net/ssh/test/packet.rb", "lib/net/ssh/test/remote_packet.rb", "lib/net/ssh/test/script.rb", "lib/net/ssh/test/socket.rb", "lib/net/ssh/test.rb", "lib/net/ssh/transport/algorithms.rb", "lib/net/ssh/transport/cipher_factory.rb", "lib/net/ssh/transport/constants.rb", "lib/net/ssh/transport/hmac/abstract.rb", "lib/net/ssh/transport/hmac/md5.rb", "lib/net/ssh/transport/hmac/md5_96.rb", "lib/net/ssh/transport/hmac/none.rb", "lib/net/ssh/transport/hmac/sha1.rb", "lib/net/ssh/transport/hmac/sha1_96.rb", "lib/net/ssh/transport/hmac.rb", "lib/net/ssh/transport/identity_cipher.rb", "lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb", "lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb", "lib/net/ssh/transport/kex.rb", "lib/net/ssh/transport/openssl.rb", "lib/net/ssh/transport/packet_stream.rb", "lib/net/ssh/transport/server_version.rb", "lib/net/ssh/transport/session.rb", "lib/net/ssh/transport/state.rb", "lib/net/ssh/verifiers/lenient.rb", "lib/net/ssh/verifiers/null.rb", "lib/net/ssh/verifiers/strict.rb", "lib/net/ssh/version.rb", "lib/net/ssh.rb", "Manifest", "net-ssh.gemspec", "Rakefile", "README.rdoc", "setup.rb", "test/authentication/methods/common.rb", "test/authentication/methods/test_abstract.rb", "test/authentication/methods/test_hostbased.rb", "test/authentication/methods/test_keyboard_interactive.rb", "test/authentication/methods/test_password.rb", "test/authentication/methods/test_publickey.rb", "test/authentication/test_agent.rb", "test/authentication/test_key_manager.rb", "test/authentication/test_session.rb", "test/common.rb", "test/configs/eqsign", "test/configs/exact_match", "test/configs/wild_cards", "test/connection/test_channel.rb", "test/connection/test_session.rb", "test/test_all.rb", "test/test_buffer.rb", "test/test_buffered_io.rb", "test/test_config.rb", "test/test_key_factory.rb", "test/transport/hmac/test_md5.rb", "test/transport/hmac/test_md5_96.rb", "test/transport/hmac/test_none.rb", "test/transport/hmac/test_sha1.rb", "test/transport/hmac/test_sha1_96.rb", "test/transport/kex/test_diffie_hellman_group1_sha1.rb", "test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb", "test/transport/test_algorithms.rb", "test/transport/test_cipher_factory.rb", "test/transport/test_hmac.rb", "test/transport/test_identity_cipher.rb", "test/transport/test_packet_stream.rb", "test/transport/test_server_version.rb", "test/transport/test_session.rb", "test/transport/test_state.rb", "THANKS.rdoc"]
12
+ s.has_rdoc = true
13
+ s.homepage = %q{http://net-ssh.rubyforge.org/ssh}
14
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-ssh", "--main", "README.rdoc"]
15
+ s.require_paths = ["lib"]
16
+ s.rubyforge_project = %q{net-ssh}
17
+ s.rubygems_version = %q{1.2.0}
18
+ s.summary = %q{a pure-Ruby implementation of the SSH2 client protocol}
19
+ s.test_files = ["test/test_all.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
24
+
25
+ if current_version >= 3 then
26
+ s.add_development_dependency(%q<echoe>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<echoe>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<echoe>, [">= 0"])
32
+ end
33
+ end