net-ssh 2.7.0 → 7.3.0

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 (199) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.dockerignore +6 -0
  4. data/.github/FUNDING.yml +1 -0
  5. data/.github/config/rubocop_linter_action.yml +4 -0
  6. data/.github/workflows/ci-with-docker.yml +44 -0
  7. data/.github/workflows/ci.yml +94 -0
  8. data/.github/workflows/rubocop.yml +16 -0
  9. data/.gitignore +15 -0
  10. data/.rubocop.yml +22 -0
  11. data/.rubocop_todo.yml +1081 -0
  12. data/CHANGES.txt +387 -0
  13. data/DEVELOPMENT.md +23 -0
  14. data/Dockerfile +29 -0
  15. data/Dockerfile.openssl3 +17 -0
  16. data/Gemfile +13 -0
  17. data/Gemfile.noed25519 +12 -0
  18. data/Gemfile.norbnacl +12 -0
  19. data/ISSUE_TEMPLATE.md +30 -0
  20. data/Manifest +4 -5
  21. data/README.md +303 -0
  22. data/Rakefile +174 -40
  23. data/SECURITY.md +4 -0
  24. data/THANKS.txt +25 -0
  25. data/appveyor.yml +58 -0
  26. data/docker-compose.yml +25 -0
  27. data/lib/net/ssh/authentication/agent.rb +279 -18
  28. data/lib/net/ssh/authentication/certificate.rb +183 -0
  29. data/lib/net/ssh/authentication/constants.rb +17 -15
  30. data/lib/net/ssh/authentication/ed25519.rb +184 -0
  31. data/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
  32. data/lib/net/ssh/authentication/key_manager.rb +125 -54
  33. data/lib/net/ssh/authentication/methods/abstract.rb +67 -48
  34. data/lib/net/ssh/authentication/methods/hostbased.rb +34 -37
  35. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +19 -12
  36. data/lib/net/ssh/authentication/methods/none.rb +16 -19
  37. data/lib/net/ssh/authentication/methods/password.rb +56 -19
  38. data/lib/net/ssh/authentication/methods/publickey.rb +96 -55
  39. data/lib/net/ssh/authentication/pageant.rb +483 -246
  40. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  41. data/lib/net/ssh/authentication/session.rb +138 -120
  42. data/lib/net/ssh/buffer.rb +399 -300
  43. data/lib/net/ssh/buffered_io.rb +154 -150
  44. data/lib/net/ssh/config.rb +361 -166
  45. data/lib/net/ssh/connection/channel.rb +640 -596
  46. data/lib/net/ssh/connection/constants.rb +29 -29
  47. data/lib/net/ssh/connection/event_loop.rb +123 -0
  48. data/lib/net/ssh/connection/keepalive.rb +59 -0
  49. data/lib/net/ssh/connection/session.rb +628 -548
  50. data/lib/net/ssh/connection/term.rb +125 -123
  51. data/lib/net/ssh/errors.rb +101 -95
  52. data/lib/net/ssh/key_factory.rb +198 -100
  53. data/lib/net/ssh/known_hosts.rb +221 -98
  54. data/lib/net/ssh/loggable.rb +50 -49
  55. data/lib/net/ssh/packet.rb +83 -79
  56. data/lib/net/ssh/prompt.rb +50 -81
  57. data/lib/net/ssh/proxy/command.rb +108 -60
  58. data/lib/net/ssh/proxy/errors.rb +12 -10
  59. data/lib/net/ssh/proxy/http.rb +82 -78
  60. data/lib/net/ssh/proxy/https.rb +50 -0
  61. data/lib/net/ssh/proxy/jump.rb +54 -0
  62. data/lib/net/ssh/proxy/socks4.rb +5 -8
  63. data/lib/net/ssh/proxy/socks5.rb +18 -20
  64. data/lib/net/ssh/service/forward.rb +383 -255
  65. data/lib/net/ssh/test/channel.rb +145 -136
  66. data/lib/net/ssh/test/extensions.rb +131 -110
  67. data/lib/net/ssh/test/kex.rb +34 -32
  68. data/lib/net/ssh/test/local_packet.rb +46 -44
  69. data/lib/net/ssh/test/packet.rb +89 -70
  70. data/lib/net/ssh/test/remote_packet.rb +32 -30
  71. data/lib/net/ssh/test/script.rb +156 -142
  72. data/lib/net/ssh/test/socket.rb +49 -48
  73. data/lib/net/ssh/test.rb +82 -77
  74. data/lib/net/ssh/transport/aes128_gcm.rb +40 -0
  75. data/lib/net/ssh/transport/aes256_gcm.rb +40 -0
  76. data/lib/net/ssh/transport/algorithms.rb +472 -348
  77. data/lib/net/ssh/transport/chacha20_poly1305_cipher.rb +117 -0
  78. data/lib/net/ssh/transport/chacha20_poly1305_cipher_loader.rb +17 -0
  79. data/lib/net/ssh/transport/cipher_factory.rb +124 -100
  80. data/lib/net/ssh/transport/constants.rb +32 -24
  81. data/lib/net/ssh/transport/ctr.rb +42 -22
  82. data/lib/net/ssh/transport/gcm_cipher.rb +207 -0
  83. data/lib/net/ssh/transport/hmac/abstract.rb +97 -63
  84. data/lib/net/ssh/transport/hmac/md5.rb +0 -2
  85. data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
  86. data/lib/net/ssh/transport/hmac/none.rb +0 -2
  87. data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
  88. data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
  89. data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
  90. data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
  91. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
  92. data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  93. data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
  94. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
  95. data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  96. data/lib/net/ssh/transport/hmac.rb +14 -12
  97. data/lib/net/ssh/transport/identity_cipher.rb +54 -44
  98. data/lib/net/ssh/transport/kex/abstract.rb +130 -0
  99. data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  100. data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
  101. data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  102. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
  103. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
  104. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +119 -213
  105. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -61
  106. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
  107. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
  108. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
  109. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
  110. data/lib/net/ssh/transport/kex.rb +15 -12
  111. data/lib/net/ssh/transport/key_expander.rb +24 -20
  112. data/lib/net/ssh/transport/openssl.rb +161 -124
  113. data/lib/net/ssh/transport/openssl_cipher_extensions.rb +8 -0
  114. data/lib/net/ssh/transport/packet_stream.rb +246 -183
  115. data/lib/net/ssh/transport/server_version.rb +57 -51
  116. data/lib/net/ssh/transport/session.rb +307 -235
  117. data/lib/net/ssh/transport/state.rb +178 -176
  118. data/lib/net/ssh/verifiers/accept_new.rb +33 -0
  119. data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
  120. data/lib/net/ssh/verifiers/always.rb +58 -0
  121. data/lib/net/ssh/verifiers/never.rb +19 -0
  122. data/lib/net/ssh/version.rb +57 -51
  123. data/lib/net/ssh.rb +140 -40
  124. data/net-ssh-public_cert.pem +21 -0
  125. data/net-ssh.gemspec +39 -184
  126. data/support/ssh_tunnel_bug.rb +5 -5
  127. data.tar.gz.sig +0 -0
  128. metadata +205 -99
  129. metadata.gz.sig +0 -0
  130. data/README.rdoc +0 -219
  131. data/Rudyfile +0 -96
  132. data/gem-public_cert.pem +0 -20
  133. data/lib/net/ssh/authentication/agent/java_pageant.rb +0 -85
  134. data/lib/net/ssh/authentication/agent/socket.rb +0 -170
  135. data/lib/net/ssh/ruby_compat.rb +0 -51
  136. data/lib/net/ssh/verifiers/lenient.rb +0 -30
  137. data/lib/net/ssh/verifiers/null.rb +0 -12
  138. data/lib/net/ssh/verifiers/secure.rb +0 -54
  139. data/lib/net/ssh/verifiers/strict.rb +0 -24
  140. data/setup.rb +0 -1585
  141. data/support/arcfour_check.rb +0 -20
  142. data/test/README.txt +0 -47
  143. data/test/authentication/methods/common.rb +0 -28
  144. data/test/authentication/methods/test_abstract.rb +0 -51
  145. data/test/authentication/methods/test_hostbased.rb +0 -114
  146. data/test/authentication/methods/test_keyboard_interactive.rb +0 -100
  147. data/test/authentication/methods/test_none.rb +0 -41
  148. data/test/authentication/methods/test_password.rb +0 -52
  149. data/test/authentication/methods/test_publickey.rb +0 -148
  150. data/test/authentication/test_agent.rb +0 -205
  151. data/test/authentication/test_key_manager.rb +0 -218
  152. data/test/authentication/test_session.rb +0 -108
  153. data/test/common.rb +0 -108
  154. data/test/configs/eqsign +0 -3
  155. data/test/configs/exact_match +0 -8
  156. data/test/configs/host_plus +0 -10
  157. data/test/configs/multihost +0 -4
  158. data/test/configs/nohost +0 -19
  159. data/test/configs/numeric_host +0 -4
  160. data/test/configs/send_env +0 -2
  161. data/test/configs/substitutes +0 -8
  162. data/test/configs/wild_cards +0 -14
  163. data/test/connection/test_channel.rb +0 -467
  164. data/test/connection/test_session.rb +0 -526
  165. data/test/known_hosts/github +0 -1
  166. data/test/manual/test_forward.rb +0 -223
  167. data/test/start/test_options.rb +0 -36
  168. data/test/start/test_transport.rb +0 -28
  169. data/test/test_all.rb +0 -11
  170. data/test/test_buffer.rb +0 -433
  171. data/test/test_buffered_io.rb +0 -63
  172. data/test/test_config.rb +0 -151
  173. data/test/test_key_factory.rb +0 -173
  174. data/test/test_known_hosts.rb +0 -13
  175. data/test/transport/hmac/test_md5.rb +0 -41
  176. data/test/transport/hmac/test_md5_96.rb +0 -27
  177. data/test/transport/hmac/test_none.rb +0 -34
  178. data/test/transport/hmac/test_ripemd160.rb +0 -36
  179. data/test/transport/hmac/test_sha1.rb +0 -36
  180. data/test/transport/hmac/test_sha1_96.rb +0 -27
  181. data/test/transport/hmac/test_sha2_256.rb +0 -37
  182. data/test/transport/hmac/test_sha2_256_96.rb +0 -27
  183. data/test/transport/hmac/test_sha2_512.rb +0 -37
  184. data/test/transport/hmac/test_sha2_512_96.rb +0 -27
  185. data/test/transport/kex/test_diffie_hellman_group14_sha1.rb +0 -13
  186. data/test/transport/kex/test_diffie_hellman_group1_sha1.rb +0 -146
  187. data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +0 -92
  188. data/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +0 -34
  189. data/test/transport/kex/test_ecdh_sha2_nistp256.rb +0 -161
  190. data/test/transport/kex/test_ecdh_sha2_nistp384.rb +0 -38
  191. data/test/transport/kex/test_ecdh_sha2_nistp521.rb +0 -38
  192. data/test/transport/test_algorithms.rb +0 -330
  193. data/test/transport/test_cipher_factory.rb +0 -443
  194. data/test/transport/test_hmac.rb +0 -34
  195. data/test/transport/test_identity_cipher.rb +0 -40
  196. data/test/transport/test_packet_stream.rb +0 -1755
  197. data/test/transport/test_server_version.rb +0 -78
  198. data/test/transport/test_session.rb +0 -319
  199. data/test/transport/test_state.rb +0 -181
data/README.md ADDED
@@ -0,0 +1,303 @@
1
+ [![Gem Version](https://badge.fury.io/rb/net-ssh.svg)](https://badge.fury.io/rb/net-ssh)
2
+ [![Join the chat at https://gitter.im/net-ssh/net-ssh](https://badges.gitter.im/net-ssh/net-ssh.svg)](https://gitter.im/net-ssh/net-ssh?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3
+ [![Build status](https://github.com/net-ssh/net-ssh/actions/workflows/ci.yml/badge.svg)](https://github.com/net-ssh/net-ssh/actions/workflows/ci.yml)
4
+ [![Coverage status](https://codecov.io/gh/net-ssh/net-ssh/branch/master/graph/badge.svg)](https://codecov.io/gh/net-ssh/net-ssh)
5
+ [![Backers on Open Collective](https://opencollective.com/net-ssh/backers/badge.svg)](#backers])
6
+ [![Sponsors on Open Collective](https://opencollective.com/net-ssh/sponsors/badge.svg)](#sponsors)
7
+
8
+ # Net::SSH 7.x
9
+
10
+ * Docs: http://net-ssh.github.io/net-ssh
11
+ * Issues: https://github.com/net-ssh/net-ssh/issues
12
+ * Codes: https://github.com/net-ssh/net-ssh
13
+ * Email: net-ssh@solutious.com
14
+
15
+ *As of v2.6.4, all gem releases are signed. See [INSTALL](#install).*
16
+
17
+ ## DESCRIPTION:
18
+
19
+ Net::SSH is a pure-Ruby implementation of the SSH2 client protocol.
20
+ It allows you to write programs that invoke and interact with processes on remote servers, via SSH2.
21
+
22
+ ## FEATURES:
23
+
24
+ * Execute processes on remote servers and capture their output
25
+ * Run multiple processes in parallel over a single SSH connection
26
+ * Support for SSH subsystems
27
+ * Forward local and remote ports via an SSH connection
28
+
29
+ ## Supported Algorithms
30
+
31
+ Net::SSH 6.0 disables by default the usage of weak algorithms.
32
+ We strongly recommend that you install a servers's version that supports the latest algorithms.
33
+
34
+ It is possible to return to the previous behavior by adding the option : `append_all_supported_algorithms: true`
35
+
36
+ Unsecure algoritms will definitely be removed in Net::SSH 8.*.
37
+
38
+ ### Host Keys
39
+
40
+ | Name | Support | Details |
41
+ |----------------------|-----------------------|----------|
42
+ | ssh-rsa | OK | |
43
+ | ssh-ed25519 | OK | Require the gem `ed25519` |
44
+ | ecdsa-sha2-nistp521 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
45
+ | ecdsa-sha2-nistp384 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
46
+ | ecdsa-sha2-nistp256 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
47
+ | ssh-dss | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
48
+
49
+ ### Key Exchange
50
+
51
+ | Name | Support | Details |
52
+ |--------------------------------------|-----------------------|----------|
53
+ | curve25519-sha256 | OK | Require the gem `x25519` |
54
+ | ecdh-sha2-nistp521 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
55
+ | ecdh-sha2-nistp384 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
56
+ | ecdh-sha2-nistp256 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
57
+ | diffie-hellman-group1-sha1 | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
58
+ | diffie-hellman-group14-sha1 | OK | |
59
+ | diffie-hellman-group-exchange-sha1 | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
60
+ | diffie-hellman-group-exchange-sha256 | OK | |
61
+
62
+ ### Encryption algorithms (ciphers)
63
+
64
+ | Name | Support | Details |
65
+ |--------------------------------------|-----------------------|----------|
66
+ | aes256-ctr / aes192-ctr / aes128-ctr | OK | |
67
+ | chacha20-poly1305@openssh.com | OK. | Requires the gem `rbnacl` |
68
+ | aes256-cbc / aes192-cbc / aes128-cbc | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
69
+ | rijndael-cbc@lysator.liu.se | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
70
+ | blowfish-ctr blowfish-cbc | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
71
+ | cast128-ctr cast128-cbc | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
72
+ | 3des-ctr 3des-cbc | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
73
+ | idea-cbc | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
74
+ | none | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
75
+
76
+ ### Message Authentication Code algorithms
77
+
78
+ | Name | Support | Details |
79
+ |----------------------|-----------------------|----------|
80
+ | hmac-sha2-512-etm | OK | |
81
+ | hmac-sha2-256-etm | OK | |
82
+ | hmac-sha2-512 | OK | |
83
+ | hmac-sha2-256 | OK | |
84
+ | hmac-sha2-512-96 | Deprecated in 6.0 | removed from the specification, will be removed in 8.0 |
85
+ | hmac-sha2-256-96 | Deprecated in 6.0 | removed from the specification, will be removed in 8.0 |
86
+ | hmac-sha1 | OK | for backward compatibility |
87
+ | hmac-sha1-96 | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
88
+ | hmac-ripemd160 | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
89
+ | hmac-md5 | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
90
+ | hmac-md5-96 | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
91
+ | none | Deprecated in 6.0 | unsecure, will be removed in 8.0 |
92
+
93
+ ## SYNOPSIS:
94
+
95
+ In a nutshell:
96
+
97
+ ```ruby
98
+ require 'net/ssh'
99
+
100
+ Net::SSH.start('host', 'user', password: "password") do |ssh|
101
+
102
+ # capture all stderr and stdout output from a remote process
103
+ output = ssh.exec!("hostname")
104
+ puts output
105
+
106
+ # capture only stdout matching a particular pattern
107
+ stdout = ""
108
+ ssh.exec!("ls -l /home/jamis") do |channel, stream, data|
109
+ stdout << data if stream == :stdout && /foo/.match(data)
110
+ end
111
+ puts stdout
112
+
113
+ # run multiple processes in parallel to completion
114
+ ssh.exec "sed ..."
115
+ ssh.exec "awk ..."
116
+ ssh.exec "rm -rf ..."
117
+ ssh.loop
118
+
119
+ # open a new channel and configure a minimal set of callbacks, then run
120
+ # the event loop until the channel finishes (closes)
121
+ channel = ssh.open_channel do |ch|
122
+ ch.exec "/usr/local/bin/ruby /path/to/file.rb" do |ch, success|
123
+ raise "could not execute command" unless success
124
+
125
+ # "on_data" is called when the process writes something to stdout
126
+ ch.on_data do |c, data|
127
+ $stdout.print data
128
+ end
129
+
130
+ # "on_extended_data" is called when the process writes something to stderr
131
+ ch.on_extended_data do |c, type, data|
132
+ $stderr.print data
133
+ end
134
+
135
+ ch.on_close { puts "done!" }
136
+ end
137
+ end
138
+
139
+ channel.wait
140
+
141
+ # forward connections on local port 1234 to port 80 of www.capify.org
142
+ ssh.forward.local(1234, "www.capify.org", 80)
143
+ ssh.loop { true }
144
+ end
145
+ ```
146
+
147
+ See Net::SSH for more documentation, and links to further information.
148
+
149
+ ## REQUIREMENTS:
150
+
151
+ The only requirement you might be missing is the OpenSSL bindings for Ruby with a version greather than `1.0.1`.
152
+ These are built by default on most platforms, but you can verify that they're built and installed on your system by running the following command line:
153
+
154
+ ```sh
155
+ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
156
+ ```
157
+
158
+ If that spits out something like `OpenSSL 1.0.1 14 Mar 2012`, then you're set.
159
+ If you get an error, then you'll need to see about rebuilding ruby with OpenSSL support,
160
+ or (if your platform supports it) installing the OpenSSL bindings separately.
161
+
162
+ ## INSTALL:
163
+
164
+ ```sh
165
+ gem install net-ssh # might need sudo privileges
166
+ ```
167
+
168
+ NOTE: If you are running on jruby on windows you need to install `jruby-pageant` manually
169
+ (gemspec doesn't allow for platform specific dependencies at gem installation time).
170
+
171
+ However, in order to be sure the code you're installing hasn't been tampered with,
172
+ it's recommended that you verify the [signature](http://docs.rubygems.org/read/chapter/21).
173
+ To do this, you need to add my public key as a trusted certificate (you only need to do this once):
174
+
175
+ ```sh
176
+ # Add the public key as a trusted certificate
177
+ # (You only need to do this once)
178
+ curl -O https://raw.githubusercontent.com/net-ssh/net-ssh/master/net-ssh-public_cert.pem
179
+ gem cert --add net-ssh-public_cert.pem
180
+ ```
181
+
182
+ Then, when install the gem, do so with high security:
183
+
184
+ ```sh
185
+ gem install net-ssh -P HighSecurity
186
+ ```
187
+
188
+ If you don't add the public key, you'll see an error like "Couldn't verify data signature".
189
+ If you're still having trouble let me know and I'll give you a hand.
190
+
191
+ For ed25519 public key auth support your bundle file should contain `ed25519`, `bcrypt_pbkdf` dependencies.
192
+
193
+ ```sh
194
+ gem install ed25519
195
+ gem install bcrypt_pbkdf
196
+ ```
197
+
198
+ For curve25519-sha256 kex exchange support your bundle file should contain `x25519` dependency.
199
+
200
+ ## RUBY SUPPORT
201
+
202
+ * See [net-ssh.gemspec](https://github.com/net-ssh/net-ssh/blob/master/net-ssh.gemspec) for current versions ruby requirements
203
+
204
+ ## RUNNING TESTS
205
+
206
+ If you want to run the tests or use any of the Rake tasks, you'll need Mocha and
207
+ other dependencies listed in Gemfile
208
+
209
+ Run the test suite from the net-ssh directory with the following command:
210
+
211
+ ```sh
212
+ bundle exec rake test
213
+ ```
214
+
215
+ NOTE : you can run test on all ruby versions with docker :
216
+
217
+ ```
218
+ docker-compose up --build
219
+ ```
220
+
221
+ Run a single test file like this:
222
+
223
+ ```sh
224
+ ruby -Ilib -Itest test/transport/test_server_version.rb
225
+ ```
226
+
227
+ To run integration tests see [here](test/integration/README.md)
228
+
229
+ ### BUILDING GEM
230
+
231
+ ```sh
232
+ rake build
233
+ ```
234
+
235
+ ### GEM SIGNING (for maintainers)
236
+
237
+ If you have the net-ssh private signing key, you will be able to create signed release builds. Make sure the private key path matches the `signing_key` path set in `net-ssh.gemspec` and tell rake to sign the gem by setting the `NET_SSH_BUILDGEM_SIGNED` flag:
238
+
239
+ ```sh
240
+ NET_SSH_BUILDGEM_SIGNED=true rake build
241
+ ```
242
+
243
+ For time to time, the public certificate associated to the private key needs to be renewed. You can do this with the following command:
244
+
245
+ ```sh
246
+ gem cert --build netssh@solutious.com --private-key path/2/net-ssh-private_key.pem
247
+ mv gem-public_cert.pem net-ssh-public_cert.pem
248
+ gem cert --add net-ssh-public_cert.pem
249
+ ```
250
+
251
+ or `rake cert:update_public_when_expired`
252
+
253
+ ## Security contact information
254
+
255
+ See [SECURITY.md](SECURITY.md)
256
+
257
+ ## CREDITS
258
+
259
+ ### Contributors
260
+
261
+ This project exists thanks to all the people who contribute.
262
+
263
+ [![contributors](https://opencollective.com/net-ssh/contributors.svg?width=890&button=false)](graphs/contributors)
264
+
265
+ ### Backers
266
+
267
+ Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/net-ssh#backer)
268
+
269
+ [![backers](https://opencollective.com/net-ssh/backers.svg?width=890)](https://opencollective.com/net-ssh#backers)
270
+
271
+ ### Sponsors
272
+
273
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://opencollective.com/net-ssh#sponsor)
274
+
275
+ [![Sponsor](https://opencollective.com/net-ssh/sponsor/0/avatar.svg)](https://opencollective.com/net-ssh/sponsor/0/website)
276
+
277
+ [<img src="https://github.com/net-ssh/net-ssh/assets/52435/9690bf3e-34ea-4c52-8aea-1cc4cb5bcb6d" width="320">](https://ubicloud.com)
278
+
279
+
280
+ ## LICENSE:
281
+
282
+ (The MIT License)
283
+
284
+ Copyright (c) 2008 Jamis Buck
285
+
286
+ Permission is hereby granted, free of charge, to any person obtaining
287
+ a copy of this software and associated documentation files (the
288
+ 'Software'), to deal in the Software without restriction, including
289
+ without limitation the rights to use, copy, modify, merge, publish,
290
+ distribute, sublicense, and/or sell copies of the Software, and to
291
+ permit persons to whom the Software is furnished to do so, subject to
292
+ the following conditions:
293
+
294
+ The above copyright notice and this permission notice shall be
295
+ included in all copies or substantial portions of the Software.
296
+
297
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
298
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
299
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
300
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
301
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
302
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
303
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,62 +1,196 @@
1
+ #
2
+ # Also in your terminal environment run:
3
+ # $ export LANG=en_US.UTF-8
4
+ # $ export LANGUAGE=en_US.UTF-8
5
+ # $ export LC_ALL=en_US.UTF-8
6
+
1
7
  require "rubygems"
2
8
  require "rake"
3
9
  require "rake/clean"
10
+ require "bundler/gem_tasks"
11
+
4
12
  require "rdoc/task"
5
13
 
6
- task :default => ["build"]
7
- CLEAN.include [ 'pkg', 'rdoc' ]
14
+ desc "When releasing make sure NET_SSH_BUILDGEM_SIGNED is set"
15
+ task :check_NET_SSH_BUILDGEM_SIGNED do
16
+ raise "NET_SSH_BUILDGEM_SIGNED should be set to release" unless ENV['NET_SSH_BUILDGEM_SIGNED']
17
+ end
18
+
19
+ Rake::Task[:release].enhance [:check_NET_SSH_BUILDGEM_SIGNED]
20
+ Rake::Task[:release].prerequisites.unshift(:check_NET_SSH_BUILDGEM_SIGNED)
21
+
22
+ task default: ["build"]
23
+ CLEAN.include ['pkg', 'rdoc']
8
24
  name = "net-ssh"
9
25
 
10
- $:.unshift File.join(File.dirname(__FILE__), 'lib')
11
- require "net/ssh"
26
+ require_relative "lib/net/ssh/version"
12
27
  version = Net::SSH::Version::CURRENT
13
28
 
14
- begin
15
- require "jeweler"
16
- Jeweler::Tasks.new do |s|
17
- s.version = version
18
- s.name = name
19
- s.rubyforge_project = s.name
20
- s.summary = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
21
- s.description = s.summary + " It allows you to write programs that invoke and interact with processes on remote servers, via SSH2."
22
- s.email = "net-ssh@solutious.com"
23
- s.homepage = "https://github.com/net-ssh/net-ssh"
24
- s.authors = ["Jamis Buck", "Delano Mandelbaum"]
25
-
26
- # Note: this is run at package time not install time so if you are
27
- # running on jruby, you need to install jruby-pageant manually.
28
- if RUBY_PLATFORM == "java"
29
- s.add_dependency 'jruby-pageant', ">=1.1.1"
29
+ extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt]
30
+ RDoc::Task.new do |rdoc|
31
+ rdoc.rdoc_dir = "rdoc"
32
+ rdoc.title = "#{name} #{version}"
33
+ rdoc.generator = 'hanna' # gem install hanna-nouveau
34
+ rdoc.main = 'README.md'
35
+ rdoc.rdoc_files.include("README*")
36
+ rdoc.rdoc_files.include("bin/*.rb")
37
+ rdoc.rdoc_files.include("lib/**/*.rb")
38
+ extra_files.each { |file|
39
+ rdoc.rdoc_files.include(file) if File.exist?(file)
40
+ }
41
+ end
42
+
43
+ namespace :cert do
44
+ desc "Update public cert from private - only run if public is expired"
45
+ task :update_public_when_expired do
46
+ require 'openssl'
47
+ require 'time'
48
+ raw = File.read "net-ssh-public_cert.pem"
49
+ certificate = OpenSSL::X509::Certificate.new raw
50
+ raise Exception, "Not yet expired: #{certificate.not_after}" unless certificate.not_after < Time.now
51
+
52
+ sh "gem cert --build netssh@solutious.com --days 365*5 --private-key /mnt/gem/net-ssh-private_key.pem"
53
+ sh "mv gem-public_cert.pem net-ssh-public_cert.pem"
54
+ sh "gem cert --add net-ssh-public_cert.pem"
55
+ end
56
+ end
57
+
58
+ def change_version(&block)
59
+ version_file = 'lib/net/ssh/version.rb'
60
+ require_relative version_file
61
+ pre = Net::SSH::Version::PRE
62
+ tiny = Net::SSH::Version::TINY
63
+ result = block[pre: pre, tiny: Net::SSH::Version::TINY]
64
+ raise ArgumentError, "Version change logic should always return a pre" unless result.key?(:pre)
65
+
66
+ new_pre = result[:pre]
67
+ new_tiny = result[:tiny] || tiny
68
+ found = { pre: false, tiny: false }
69
+ File.open("#{version_file}.new", "w") do |f|
70
+ File.readlines(version_file).each do |line|
71
+ match =
72
+ if pre.nil?
73
+ /^(\s+PRE\s+=\s+)nil(\s*)$/.match(line)
74
+ else
75
+ /^(\s+PRE\s+=\s+")#{pre}("\s*)$/.match(line)
76
+ end
77
+ if match
78
+ prefix = match[1]
79
+ postfix = match[2]
80
+ prefix.delete_suffix!('"')
81
+ postfix.delete_prefix!('"')
82
+ new_line = "#{prefix}#{new_pre.inspect}#{postfix}"
83
+ puts "Changing:\n - #{line} + #{new_line}"
84
+ line = new_line
85
+ found[:pre] = true
86
+ end
87
+
88
+ if new_tiny != tiny
89
+ match = /^(\s+TINY\s+=\s+)#{tiny}(\s*)$/.match(line)
90
+ if match
91
+ prefix = match[1]
92
+ postfix = match[2]
93
+ new_line = "#{prefix}#{new_tiny}#{postfix}"
94
+ puts "Changing:\n - #{line} + #{new_line}"
95
+ line = new_line
96
+ found[:tiny] = true
97
+ end
98
+ end
99
+
100
+ f.write(line)
30
101
  end
102
+ raise ArgumentError, "Cound not find line: PRE = \"#{pre}\" in #{version_file}" unless found[:pre]
103
+ raise ArgumentError, "Cound not find line: TINY = \"#{tiny}\" in #{version_file}" unless found[:tiny] || new_tiny == tiny
104
+ end
31
105
 
32
- s.add_development_dependency 'test-unit'
33
- s.add_development_dependency 'mocha'
106
+ FileUtils.mv version_file, "#{version_file}.old"
107
+ FileUtils.mv "#{version_file}.new", version_file
108
+ end
34
109
 
35
- s.license = "MIT"
110
+ namespace :vbump do
111
+ desc "Final release"
112
+ task :final do
113
+ change_version do |pre:, tiny:|
114
+ _ = tiny
115
+ if pre.nil?
116
+ { tiny: tiny + 1, pre: nil }
117
+ else
118
+ raise ArgumentError, "Unexpected pre: #{pre}" if pre.nil?
36
119
 
37
- #s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
38
- #s.cert_chain = ['gem-public_cert.pem']
120
+ { pre: nil }
121
+ end
122
+ end
123
+ end
124
+
125
+ desc "Increment prerelease"
126
+ task :pre, [:type] do |_t, args|
127
+ change_version do |pre:, tiny:|
128
+ puts " PRE => #{pre.inspect}"
129
+ match = /^([a-z]+)(\d+)/.match(pre)
130
+ raise ArgumentError, "Unexpected pre: #{pre}" if match.nil? && args[:type].nil?
131
+
132
+ if match.nil? || (!args[:type].nil? && args[:type] != match[1])
133
+ if pre.nil?
134
+ { pre: "#{args[:type]}1", tiny: tiny + 1 }
135
+ else
136
+ { pre: "#{args[:type]}1" }
137
+ end
138
+ else
139
+ { pre: "#{match[1]}#{match[2].to_i + 1}" }
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ namespace :rdoc do
146
+ desc "Update gh-pages branch"
147
+ task :publish do
148
+ # copy/checkout
149
+ rm_rf "/tmp/net-ssh-rdoc"
150
+ rm_rf "/tmp/net-ssh-gh-pages"
151
+ cp_r "./rdoc", "/tmp/net-ssh-rdoc"
152
+ mkdir "/tmp/net-ssh-gh-pages"
153
+ Dir.chdir "/tmp/net-ssh-gh-pages" do
154
+ sh "git clone --branch gh-pages --single-branch https://github.com/net-ssh/net-ssh"
155
+ rm_rf "/tmp/net-ssh-gh-pages/net-ssh/*"
156
+ end
157
+ # update
158
+ sh "cp -rf ./rdoc/* /tmp/net-ssh-gh-pages/net-ssh/"
159
+ Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
160
+ sh "git add -A ."
161
+ sh "git commit -m \"Update docs\""
162
+ end
163
+ # publish
164
+ Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
165
+ sh "git push origin gh-pages"
166
+ end
39
167
  end
40
- Jeweler::GemcutterTasks.new
41
- rescue LoadError
42
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
43
168
  end
44
169
 
45
170
  require 'rake/testtask'
171
+
46
172
  Rake::TestTask.new do |t|
47
173
  t.libs = ["lib", "test"]
174
+ t.libs << "test/integration" if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
175
+ t.libs << "test/win_integration" if ENV['NET_SSH_RUN_WIN_INTEGRATION_TESTS']
176
+ test_files = FileList['test/**/test_*.rb']
177
+ test_files -= FileList['test/integration/**/test_*.rb'] unless ENV['NET_SSH_RUN_INTEGRATION_TESTS']
178
+ test_files -= FileList['test/win_integration/**/test_*.rb'] unless ENV['NET_SSH_RUN_WIN_INTEGRATION_TESTS']
179
+ test_files -= FileList['test/manual/test_*.rb']
180
+ test_files -= FileList['test/test_pageant.rb']
181
+ test_files -= FileList['test/test/**/test_*.rb']
182
+ t.test_files = test_files
48
183
  end
49
184
 
50
- extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ]
51
- RDoc::Task.new do |rdoc|
52
- rdoc.rdoc_dir = "rdoc"
53
- rdoc.title = "#{name} #{version}"
54
- rdoc.generator = 'hanna' # gem install hanna-nouveau
55
- rdoc.main = 'README.rdoc'
56
- rdoc.rdoc_files.include("README*")
57
- rdoc.rdoc_files.include("bin/*.rb")
58
- rdoc.rdoc_files.include("lib/**/*.rb")
59
- extra_files.each { |file|
60
- rdoc.rdoc_files.include(file) if File.exists?(file)
61
- }
185
+ # We need to enable the OpenSSL 3.0 legacy providers for our test suite
186
+ require 'openssl'
187
+ ENV['OPENSSL_CONF'] = 'test/openssl3.conf' if OpenSSL::OPENSSL_LIBRARY_VERSION.start_with? "OpenSSL 3"
188
+
189
+ desc "Run tests of Net::SSH:Test"
190
+ Rake::TestTask.new do |t|
191
+ t.name = "test_test"
192
+ # we need to run test/test separatedly as it hacks io + other modules
193
+ t.libs = ["lib", "test"]
194
+ test_files = FileList['test/test/**/test_*.rb']
195
+ t.test_files = test_files
62
196
  end
data/SECURITY.md ADDED
@@ -0,0 +1,4 @@
1
+ ## Security contact information
2
+
3
+ To report a security vulnerability, please use the
4
+ [GitHub private vulnerability reporting feature](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
data/THANKS.txt CHANGED
@@ -19,6 +19,30 @@ Chris Andrews <chris@nodnol.org> and Lee Jensen <lee@outerim.com>
19
19
  Hiroshi Nakamura
20
20
  * fixed errors with JRuby tests
21
21
 
22
+ bobveznat
23
+ therealjessesanford
24
+ liggitt
25
+ jarredholman
26
+ yugui
27
+ SFEley
28
+ bobtfish
29
+ carlhoerberg
30
+ deric
31
+ mirakui
32
+ ecki
33
+ Dave Sieh
34
+ metametaclass
35
+ fnordfish
36
+ krishicks
37
+ noric
38
+ GabKlein
39
+ Josh Kalderimis
40
+ voxik
41
+ Olipro
42
+ jansegre
43
+ priteau
44
+ jordimassaguerpla
45
+ Kenichi Kamiya
22
46
  Andreas Wolff
23
47
  mhuffnagle
24
48
  ohrite
@@ -83,3 +107,4 @@ watsonian
83
107
  Grant Hutchins
84
108
  Michael Schubert
85
109
  mtrudel
110
+ Aurélien Derouineau
data/appveyor.yml ADDED
@@ -0,0 +1,58 @@
1
+ version: '{build}'
2
+
3
+ skip_tags: true
4
+
5
+ environment:
6
+ matrix:
7
+ - ruby_version: "jruby-9.1.2.0"
8
+ - ruby_version: "26-x64"
9
+ - ruby_version: "25-x64"
10
+ - ruby_version: "24-x64"
11
+ - ruby_version: "23"
12
+ - ruby_version: "23-x64"
13
+
14
+ matrix:
15
+ allow_failures:
16
+ - ruby_version: "jruby-9.1.2.0"
17
+
18
+ #init:
19
+ # - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
20
+
21
+ #on_finish:
22
+ # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
23
+
24
+
25
+ platform:
26
+ - x86
27
+
28
+ install:
29
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
30
+ - if "%ruby_version%" == "jruby-9.1.2.0" ( cinst javaruntime -i )
31
+ - if "%ruby_version%" == "jruby-9.1.2.0" ( cinst jruby --version 9.1.2.0 -i --allow-empty-checksums )
32
+ - if "%ruby_version%" == "jruby-9.1.2.0" ( SET "PATH=C:\jruby-9.1.2.0\bin\;%PATH%" )
33
+ - ruby --version
34
+ - gem install bundler --no-document --user-install -v 1.17
35
+ - SET BUNDLE_GEMFILE=Gemfile.noed25519
36
+ - bundle install --retry=3
37
+ - cinst freesshd
38
+ - cinst putty --allow-empty-checksums
39
+ - ps: |
40
+ if ($env:Processor_Architecture -eq "x86")
41
+ {
42
+ dir 'C:\Program Files\'
43
+ dir 'C:\Program Files\freeSSHd'
44
+ cp 'test\win_integration\FreeSSHDService.ini' 'C:\Program Files\freeSSHd\FreeSSHDService.ini'
45
+ & 'C:\Program Files\freeSSHd\FreeSSHDService.exe'
46
+ } else {
47
+ dir 'C:\Program Files (x86)\'
48
+ dir 'C:\Program Files (x86)\freeSSHd'
49
+ cp 'test\win_integration\FreeSSHDService32.ini' 'C:\Program Files (x86)\freeSSHd\FreeSSHDService.ini'
50
+ & 'C:\Program Files (x86)\freeSSHd\FreeSSHDService.exe'
51
+ }
52
+
53
+ test_script:
54
+ - SET BUNDLE_GEMFILE=Gemfile.noed25519
55
+ - SET NET_SSH_RUN_WIN_INTEGRATION_TESTS=YES
56
+ - bundle exec rake test
57
+
58
+ build: off
@@ -0,0 +1,25 @@
1
+ version: '3'
2
+
3
+ services:
4
+ ruby-3.1:
5
+ build:
6
+ context: .
7
+ args:
8
+ RUBY_VERSION: 3.1
9
+ ruby-3.0:
10
+ build:
11
+ context: .
12
+ args:
13
+ RUBY_VERSION: 3.0
14
+ ruby-2.7:
15
+ build:
16
+ context: .
17
+ args:
18
+ RUBY_VERSION: 2.7
19
+ BUNDLERV: "-v 2.2.28"
20
+ ruby-2.6:
21
+ build:
22
+ context: .
23
+ args:
24
+ RUBY_VERSION: 2.6
25
+ BUNDLERV: "-v 2.4.22"