net-ssh 3.2.0 → 7.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +5 -5
  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 +93 -0
  8. data/.github/workflows/rubocop.yml +16 -0
  9. data/.gitignore +13 -0
  10. data/.rubocop.yml +22 -0
  11. data/.rubocop_todo.yml +1081 -0
  12. data/CHANGES.txt +237 -7
  13. data/DEVELOPMENT.md +23 -0
  14. data/Dockerfile +27 -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 +298 -0
  22. data/Rakefile +125 -74
  23. data/SECURITY.md +4 -0
  24. data/appveyor.yml +58 -0
  25. data/docker-compose.yml +23 -0
  26. data/lib/net/ssh/authentication/agent.rb +279 -18
  27. data/lib/net/ssh/authentication/certificate.rb +183 -0
  28. data/lib/net/ssh/authentication/constants.rb +17 -15
  29. data/lib/net/ssh/authentication/ed25519.rb +186 -0
  30. data/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
  31. data/lib/net/ssh/authentication/key_manager.rb +86 -39
  32. data/lib/net/ssh/authentication/methods/abstract.rb +67 -48
  33. data/lib/net/ssh/authentication/methods/hostbased.rb +34 -37
  34. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +13 -13
  35. data/lib/net/ssh/authentication/methods/none.rb +16 -19
  36. data/lib/net/ssh/authentication/methods/password.rb +27 -17
  37. data/lib/net/ssh/authentication/methods/publickey.rb +96 -55
  38. data/lib/net/ssh/authentication/pageant.rb +471 -367
  39. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  40. data/lib/net/ssh/authentication/session.rb +131 -121
  41. data/lib/net/ssh/buffer.rb +399 -300
  42. data/lib/net/ssh/buffered_io.rb +154 -150
  43. data/lib/net/ssh/config.rb +308 -185
  44. data/lib/net/ssh/connection/channel.rb +635 -613
  45. data/lib/net/ssh/connection/constants.rb +29 -29
  46. data/lib/net/ssh/connection/event_loop.rb +123 -0
  47. data/lib/net/ssh/connection/keepalive.rb +55 -51
  48. data/lib/net/ssh/connection/session.rb +620 -551
  49. data/lib/net/ssh/connection/term.rb +125 -123
  50. data/lib/net/ssh/errors.rb +101 -99
  51. data/lib/net/ssh/key_factory.rb +197 -105
  52. data/lib/net/ssh/known_hosts.rb +214 -127
  53. data/lib/net/ssh/loggable.rb +50 -49
  54. data/lib/net/ssh/packet.rb +83 -79
  55. data/lib/net/ssh/prompt.rb +50 -81
  56. data/lib/net/ssh/proxy/command.rb +105 -90
  57. data/lib/net/ssh/proxy/errors.rb +12 -10
  58. data/lib/net/ssh/proxy/http.rb +82 -79
  59. data/lib/net/ssh/proxy/https.rb +50 -0
  60. data/lib/net/ssh/proxy/jump.rb +54 -0
  61. data/lib/net/ssh/proxy/socks4.rb +2 -6
  62. data/lib/net/ssh/proxy/socks5.rb +14 -17
  63. data/lib/net/ssh/service/forward.rb +370 -317
  64. data/lib/net/ssh/test/channel.rb +145 -136
  65. data/lib/net/ssh/test/extensions.rb +131 -110
  66. data/lib/net/ssh/test/kex.rb +34 -32
  67. data/lib/net/ssh/test/local_packet.rb +46 -44
  68. data/lib/net/ssh/test/packet.rb +89 -70
  69. data/lib/net/ssh/test/remote_packet.rb +32 -30
  70. data/lib/net/ssh/test/script.rb +156 -142
  71. data/lib/net/ssh/test/socket.rb +49 -48
  72. data/lib/net/ssh/test.rb +82 -77
  73. data/lib/net/ssh/transport/algorithms.rb +462 -359
  74. data/lib/net/ssh/transport/chacha20_poly1305_cipher.rb +117 -0
  75. data/lib/net/ssh/transport/chacha20_poly1305_cipher_loader.rb +17 -0
  76. data/lib/net/ssh/transport/cipher_factory.rb +122 -99
  77. data/lib/net/ssh/transport/constants.rb +32 -24
  78. data/lib/net/ssh/transport/ctr.rb +42 -22
  79. data/lib/net/ssh/transport/hmac/abstract.rb +81 -63
  80. data/lib/net/ssh/transport/hmac/md5.rb +0 -2
  81. data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
  82. data/lib/net/ssh/transport/hmac/none.rb +0 -2
  83. data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
  84. data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
  85. data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
  86. data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
  87. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
  88. data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  89. data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
  90. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
  91. data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  92. data/lib/net/ssh/transport/hmac.rb +14 -12
  93. data/lib/net/ssh/transport/identity_cipher.rb +54 -44
  94. data/lib/net/ssh/transport/kex/abstract.rb +130 -0
  95. data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  96. data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
  97. data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  98. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
  99. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
  100. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +119 -213
  101. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -61
  102. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
  103. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
  104. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
  105. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
  106. data/lib/net/ssh/transport/kex.rb +15 -12
  107. data/lib/net/ssh/transport/key_expander.rb +24 -20
  108. data/lib/net/ssh/transport/openssl.rb +161 -124
  109. data/lib/net/ssh/transport/openssl_cipher_extensions.rb +8 -0
  110. data/lib/net/ssh/transport/packet_stream.rb +246 -185
  111. data/lib/net/ssh/transport/server_version.rb +55 -56
  112. data/lib/net/ssh/transport/session.rb +306 -255
  113. data/lib/net/ssh/transport/state.rb +178 -176
  114. data/lib/net/ssh/verifiers/accept_new.rb +33 -0
  115. data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
  116. data/lib/net/ssh/verifiers/always.rb +58 -0
  117. data/lib/net/ssh/verifiers/never.rb +19 -0
  118. data/lib/net/ssh/version.rb +55 -53
  119. data/lib/net/ssh.rb +111 -47
  120. data/net-ssh-public_cert.pem +18 -18
  121. data/net-ssh.gemspec +38 -205
  122. data/support/ssh_tunnel_bug.rb +5 -5
  123. data.tar.gz.sig +0 -0
  124. metadata +173 -118
  125. metadata.gz.sig +0 -0
  126. data/.travis.yml +0 -18
  127. data/README.rdoc +0 -182
  128. data/lib/net/ssh/authentication/agent/java_pageant.rb +0 -85
  129. data/lib/net/ssh/authentication/agent/socket.rb +0 -178
  130. data/lib/net/ssh/ruby_compat.rb +0 -46
  131. data/lib/net/ssh/verifiers/lenient.rb +0 -30
  132. data/lib/net/ssh/verifiers/null.rb +0 -12
  133. data/lib/net/ssh/verifiers/secure.rb +0 -52
  134. data/lib/net/ssh/verifiers/strict.rb +0 -24
  135. data/setup.rb +0 -1585
  136. data/support/arcfour_check.rb +0 -20
  137. data/test/README.txt +0 -18
  138. data/test/authentication/methods/common.rb +0 -28
  139. data/test/authentication/methods/test_abstract.rb +0 -51
  140. data/test/authentication/methods/test_hostbased.rb +0 -114
  141. data/test/authentication/methods/test_keyboard_interactive.rb +0 -121
  142. data/test/authentication/methods/test_none.rb +0 -41
  143. data/test/authentication/methods/test_password.rb +0 -95
  144. data/test/authentication/methods/test_publickey.rb +0 -148
  145. data/test/authentication/test_agent.rb +0 -232
  146. data/test/authentication/test_key_manager.rb +0 -240
  147. data/test/authentication/test_session.rb +0 -107
  148. data/test/common.rb +0 -125
  149. data/test/configs/auth_off +0 -5
  150. data/test/configs/auth_on +0 -4
  151. data/test/configs/empty +0 -0
  152. data/test/configs/eqsign +0 -3
  153. data/test/configs/exact_match +0 -8
  154. data/test/configs/host_plus +0 -10
  155. data/test/configs/multihost +0 -4
  156. data/test/configs/negative_match +0 -6
  157. data/test/configs/nohost +0 -19
  158. data/test/configs/numeric_host +0 -4
  159. data/test/configs/proxy_remote_user +0 -2
  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 -487
  164. data/test/connection/test_session.rb +0 -564
  165. data/test/integration/README.txt +0 -17
  166. data/test/integration/Vagrantfile +0 -12
  167. data/test/integration/common.rb +0 -63
  168. data/test/integration/playbook.yml +0 -56
  169. data/test/integration/test_forward.rb +0 -637
  170. data/test/integration/test_id_rsa_keys.rb +0 -96
  171. data/test/integration/test_proxy.rb +0 -93
  172. data/test/known_hosts/github +0 -1
  173. data/test/known_hosts/github_hash +0 -1
  174. data/test/manual/test_pageant.rb +0 -37
  175. data/test/start/test_connection.rb +0 -53
  176. data/test/start/test_options.rb +0 -57
  177. data/test/start/test_transport.rb +0 -28
  178. data/test/start/test_user_nil.rb +0 -27
  179. data/test/test_all.rb +0 -12
  180. data/test/test_buffer.rb +0 -433
  181. data/test/test_buffered_io.rb +0 -63
  182. data/test/test_config.rb +0 -268
  183. data/test/test_key_factory.rb +0 -191
  184. data/test/test_known_hosts.rb +0 -66
  185. data/test/transport/hmac/test_md5.rb +0 -41
  186. data/test/transport/hmac/test_md5_96.rb +0 -27
  187. data/test/transport/hmac/test_none.rb +0 -34
  188. data/test/transport/hmac/test_ripemd160.rb +0 -36
  189. data/test/transport/hmac/test_sha1.rb +0 -36
  190. data/test/transport/hmac/test_sha1_96.rb +0 -27
  191. data/test/transport/hmac/test_sha2_256.rb +0 -37
  192. data/test/transport/hmac/test_sha2_256_96.rb +0 -27
  193. data/test/transport/hmac/test_sha2_512.rb +0 -37
  194. data/test/transport/hmac/test_sha2_512_96.rb +0 -27
  195. data/test/transport/kex/test_diffie_hellman_group14_sha1.rb +0 -13
  196. data/test/transport/kex/test_diffie_hellman_group1_sha1.rb +0 -150
  197. data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +0 -96
  198. data/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +0 -19
  199. data/test/transport/kex/test_ecdh_sha2_nistp256.rb +0 -161
  200. data/test/transport/kex/test_ecdh_sha2_nistp384.rb +0 -38
  201. data/test/transport/kex/test_ecdh_sha2_nistp521.rb +0 -38
  202. data/test/transport/test_algorithms.rb +0 -328
  203. data/test/transport/test_cipher_factory.rb +0 -443
  204. data/test/transport/test_hmac.rb +0 -34
  205. data/test/transport/test_identity_cipher.rb +0 -40
  206. data/test/transport/test_packet_stream.rb +0 -1762
  207. data/test/transport/test_server_version.rb +0 -74
  208. data/test/transport/test_session.rb +0 -331
  209. data/test/transport/test_state.rb +0 -181
  210. data/test/verifiers/test_secure.rb +0 -40
data/README.md ADDED
@@ -0,0 +1,298 @@
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
+ ## Security contact information
252
+
253
+ See [SECURITY.md](SECURITY.md)
254
+
255
+ ## CREDITS
256
+
257
+ ### Contributors
258
+
259
+ This project exists thanks to all the people who contribute.
260
+
261
+ [![contributors](https://opencollective.com/net-ssh/contributors.svg?width=890&button=false)](graphs/contributors)
262
+
263
+ ### Backers
264
+
265
+ Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/net-ssh#backer)
266
+
267
+ [![backers](https://opencollective.com/net-ssh/backers.svg?width=890)](https://opencollective.com/net-ssh#backers)
268
+
269
+ ### Sponsors
270
+
271
+ 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)
272
+
273
+ [![Sponsor](https://opencollective.com/net-ssh/sponsor/0/avatar.svg)](https://opencollective.com/net-ssh/sponsor/0/website)
274
+
275
+ ## LICENSE:
276
+
277
+ (The MIT License)
278
+
279
+ Copyright (c) 2008 Jamis Buck
280
+
281
+ Permission is hereby granted, free of charge, to any person obtaining
282
+ a copy of this software and associated documentation files (the
283
+ 'Software'), to deal in the Software without restriction, including
284
+ without limitation the rights to use, copy, modify, merge, publish,
285
+ distribute, sublicense, and/or sell copies of the Software, and to
286
+ permit persons to whom the Software is furnished to do so, subject to
287
+ the following conditions:
288
+
289
+ The above copyright notice and this permission notice shall be
290
+ included in all copies or substantial portions of the Software.
291
+
292
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
293
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
294
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
295
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
296
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
297
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
298
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- # coding: UTF-8
2
1
  #
3
2
  # Also in your terminal environment run:
4
3
  # $ export LANG=en_US.UTF-8
@@ -8,105 +7,157 @@
8
7
  require "rubygems"
9
8
  require "rake"
10
9
  require "rake/clean"
11
- if RUBY_VERSION >= '1.9.0'
12
- require "rdoc/task"
13
-
14
- task :default => ["build"]
15
- CLEAN.include [ 'pkg', 'rdoc' ]
16
- name = "net-ssh"
10
+ require "bundler/gem_tasks"
17
11
 
18
- $:.unshift File.join(File.dirname(__FILE__), 'lib')
19
- require "net/ssh"
20
- version = Net::SSH::Version::CURRENT
12
+ require "rdoc/task"
21
13
 
22
- begin
23
- require "jeweler"
24
- Jeweler::Tasks.new do |s|
25
- s.version = version
26
- s.name = name
27
- s.rubyforge_project = s.name
28
- s.summary = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
29
- s.description = s.summary + " It allows you to write programs that invoke and interact with processes on remote servers, via SSH2."
30
- s.email = "net-ssh@solutious.com"
31
- s.homepage = "https://github.com/net-ssh/net-ssh"
32
- s.authors = ["Jamis Buck", "Delano Mandelbaum", "Miklós Fazekas"]
33
- s.required_ruby_version = '>= 2.0'
34
-
35
- # Note: this is run at package time not install time so if you are
36
- # running on jruby, you need to install jruby-pageant manually.
37
- if RUBY_PLATFORM == "java"
38
- s.add_dependency 'jruby-pageant', ">=1.1.1"
39
- end
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
40
18
 
41
- s.add_development_dependency 'test-unit'
42
- s.add_development_dependency 'mocha'
19
+ Rake::Task[:release].enhance [:check_NET_SSH_BUILDGEM_SIGNED]
20
+ Rake::Task[:release].prerequisites.unshift(:check_NET_SSH_BUILDGEM_SIGNED)
43
21
 
44
- s.license = "MIT"
22
+ task default: ["build"]
23
+ CLEAN.include ['pkg', 'rdoc']
24
+ name = "net-ssh"
45
25
 
46
- unless ENV['NET_SSH_NOKEY']
47
- signing_key = File.join('/mnt/gem/', 'net-ssh-private_key.pem')
48
- s.signing_key = File.join('/mnt/gem/', 'net-ssh-private_key.pem')
49
- s.cert_chain = ['net-ssh-public_cert.pem']
50
- unless (Rake.application.top_level_tasks & ['build','install']).empty?
51
- raise "No key found at #{signing_key} for signing, use rake <taskname> NET_SSH_NOKEY=1 to build without key" unless File.exist?(signing_key)
52
- end
53
- end
54
- end
55
- Jeweler::RubygemsDotOrgTasks.new
56
- rescue LoadError
57
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
58
- end
26
+ require_relative "lib/net/ssh/version"
27
+ version = Net::SSH::Version::CURRENT
59
28
 
60
- extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ]
29
+ extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt]
61
30
  RDoc::Task.new do |rdoc|
62
31
  rdoc.rdoc_dir = "rdoc"
63
32
  rdoc.title = "#{name} #{version}"
64
33
  rdoc.generator = 'hanna' # gem install hanna-nouveau
65
- rdoc.main = 'README.rdoc'
34
+ rdoc.main = 'README.md'
66
35
  rdoc.rdoc_files.include("README*")
67
36
  rdoc.rdoc_files.include("bin/*.rb")
68
37
  rdoc.rdoc_files.include("lib/**/*.rb")
69
38
  extra_files.each { |file|
70
- rdoc.rdoc_files.include(file) if File.exists?(file)
39
+ rdoc.rdoc_files.include(file) if File.exist?(file)
71
40
  }
72
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
73
56
  end
74
57
 
75
- namespace :rdoc do
76
- desc "Update gh-pages branch"
77
- task :publish do
78
- # copy/checkout
79
- rm_rf "/tmp/net-ssh-rdoc"
80
- rm_rf "/tmp/net-ssh-gh-pages"
81
- cp_r "./rdoc", "/tmp/net-ssh-rdoc"
82
- mkdir "/tmp/net-ssh-gh-pages"
83
- Dir.chdir "/tmp/net-ssh-gh-pages" do
84
- sh "git clone --branch gh-pages --single-branch https://github.com/net-ssh/net-ssh"
85
- rm_rf "/tmp/net-ssh-gh-pages/net-ssh/*"
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
+ result = block[pre: pre]
63
+ raise "Version change logic should always return a pre", ArgumentError unless result.key?(:pre)
64
+
65
+ new_pre = result[:pre]
66
+ found = false
67
+ File.open("#{version_file}.new", "w") do |f|
68
+ File.readlines(version_file).each do |line|
69
+ match = /^(\s+PRE\s+=\s+")#{pre}("\s*)$/.match(line)
70
+ if match
71
+ prefix = match[1]
72
+ postfix = match[2]
73
+ if new_pre.nil?
74
+ prefix.delete_suffix!('"')
75
+ postfix.delete_prefix!('"')
76
+ end
77
+ new_line = "#{prefix}#{new_pre.inspect}#{postfix}"
78
+ puts "Changing:\n - #{line} + #{new_line}"
79
+ line = new_line
80
+ found = true
81
+ end
82
+ f.write(line)
83
+ end
84
+ raise ArugmentError, "Cound not find line: PRE = \"#{pre}\" in #{version_file}" unless found
86
85
  end
87
- # update
88
- sh "cp -rf ./rdoc/* /tmp/net-ssh-gh-pages/net-ssh/"
89
- Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
90
- sh "git add -A ."
91
- sh "git commit -m \"Update docs\""
86
+
87
+ FileUtils.mv version_file, "#{version_file}.old"
88
+ FileUtils.mv "#{version_file}.new", version_file
89
+ end
90
+
91
+ namespace :vbump do
92
+ desc "Final release"
93
+ task :final do
94
+ change_version do |pre:|
95
+ raise ArgumentError, "Unexpected pre: #{pre}" if pre.nil?
96
+
97
+ { pre: nil }
98
+ end
92
99
  end
93
- # publish
94
- Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
95
- sh "git push origin gh-pages"
100
+
101
+ desc "Increment prerelease"
102
+ task :pre do
103
+ change_version do |pre:|
104
+ match = /^([a-z]+)(\d+)/.match(pre)
105
+ raise ArgumentError, "Unexpected pre: #{pre}" if match.nil?
106
+
107
+ { pre: "#{match[1]}#{match[2].to_i + 1}" }
108
+ end
96
109
  end
97
110
  end
111
+
112
+ namespace :rdoc do
113
+ desc "Update gh-pages branch"
114
+ task :publish do
115
+ # copy/checkout
116
+ rm_rf "/tmp/net-ssh-rdoc"
117
+ rm_rf "/tmp/net-ssh-gh-pages"
118
+ cp_r "./rdoc", "/tmp/net-ssh-rdoc"
119
+ mkdir "/tmp/net-ssh-gh-pages"
120
+ Dir.chdir "/tmp/net-ssh-gh-pages" do
121
+ sh "git clone --branch gh-pages --single-branch https://github.com/net-ssh/net-ssh"
122
+ rm_rf "/tmp/net-ssh-gh-pages/net-ssh/*"
123
+ end
124
+ # update
125
+ sh "cp -rf ./rdoc/* /tmp/net-ssh-gh-pages/net-ssh/"
126
+ Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
127
+ sh "git add -A ."
128
+ sh "git commit -m \"Update docs\""
129
+ end
130
+ # publish
131
+ Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
132
+ sh "git push origin gh-pages"
133
+ end
134
+ end
98
135
  end
99
136
 
100
137
  require 'rake/testtask'
138
+
101
139
  Rake::TestTask.new do |t|
102
- if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
103
- t.libs = ["lib","test","test/integration"]
104
- else
105
- t.libs = ["lib", "test"]
106
- end
140
+ t.libs = ["lib", "test"]
141
+ t.libs << "test/integration" if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
142
+ t.libs << "test/win_integration" if ENV['NET_SSH_RUN_WIN_INTEGRATION_TESTS']
143
+ test_files = FileList['test/**/test_*.rb']
144
+ test_files -= FileList['test/integration/**/test_*.rb'] unless ENV['NET_SSH_RUN_INTEGRATION_TESTS']
145
+ test_files -= FileList['test/win_integration/**/test_*.rb'] unless ENV['NET_SSH_RUN_WIN_INTEGRATION_TESTS']
146
+ test_files -= FileList['test/manual/test_*.rb']
147
+ test_files -= FileList['test/test_pageant.rb']
148
+ test_files -= FileList['test/test/**/test_*.rb']
149
+ t.test_files = test_files
107
150
  end
108
151
 
109
- Rake::TestTask.new(:'integration-test') do |t|
110
- t.libs = ["lib", "test/integration"]
111
- t.pattern = 'test/integration/test_*.rb'
152
+ # We need to enable the OpenSSL 3.0 legacy providers for our test suite
153
+ require 'openssl'
154
+ ENV['OPENSSL_CONF'] = 'test/openssl3.conf' if OpenSSL::OPENSSL_LIBRARY_VERSION.start_with? "OpenSSL 3"
155
+
156
+ desc "Run tests of Net::SSH:Test"
157
+ Rake::TestTask.new do |t|
158
+ t.name = "test_test"
159
+ # we need to run test/test separatedly as it hacks io + other modules
160
+ t.libs = ["lib", "test"]
161
+ test_files = FileList['test/test/**/test_*.rb']
162
+ t.test_files = test_files
112
163
  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/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,23 @@
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
+ ruby-2.6:
20
+ build:
21
+ context: .
22
+ args:
23
+ RUBY_VERSION: 2.6