net-ssh 3.2.0.rc2 → 7.1.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 (204) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +2 -2
  3. data/.dockerignore +6 -0
  4. data/.github/config/rubocop_linter_action.yml +4 -0
  5. data/.github/workflows/ci-with-docker.yml +44 -0
  6. data/.github/workflows/ci.yml +87 -0
  7. data/.github/workflows/rubocop.yml +16 -0
  8. data/.gitignore +13 -0
  9. data/.rubocop.yml +22 -0
  10. data/.rubocop_todo.yml +1081 -0
  11. data/CHANGES.txt +228 -7
  12. data/Dockerfile +27 -0
  13. data/Dockerfile.openssl3 +17 -0
  14. data/Gemfile +13 -0
  15. data/Gemfile.noed25519 +12 -0
  16. data/ISSUE_TEMPLATE.md +30 -0
  17. data/Manifest +4 -5
  18. data/README.md +297 -0
  19. data/Rakefile +125 -74
  20. data/SECURITY.md +4 -0
  21. data/appveyor.yml +58 -0
  22. data/docker-compose.yml +23 -0
  23. data/lib/net/ssh/authentication/agent.rb +279 -18
  24. data/lib/net/ssh/authentication/certificate.rb +183 -0
  25. data/lib/net/ssh/authentication/constants.rb +17 -15
  26. data/lib/net/ssh/authentication/ed25519.rb +186 -0
  27. data/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
  28. data/lib/net/ssh/authentication/key_manager.rb +86 -39
  29. data/lib/net/ssh/authentication/methods/abstract.rb +67 -48
  30. data/lib/net/ssh/authentication/methods/hostbased.rb +34 -37
  31. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +13 -13
  32. data/lib/net/ssh/authentication/methods/none.rb +16 -19
  33. data/lib/net/ssh/authentication/methods/password.rb +27 -17
  34. data/lib/net/ssh/authentication/methods/publickey.rb +96 -55
  35. data/lib/net/ssh/authentication/pageant.rb +471 -367
  36. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  37. data/lib/net/ssh/authentication/session.rb +131 -121
  38. data/lib/net/ssh/buffer.rb +399 -300
  39. data/lib/net/ssh/buffered_io.rb +154 -150
  40. data/lib/net/ssh/config.rb +308 -185
  41. data/lib/net/ssh/connection/channel.rb +635 -613
  42. data/lib/net/ssh/connection/constants.rb +29 -29
  43. data/lib/net/ssh/connection/event_loop.rb +123 -0
  44. data/lib/net/ssh/connection/keepalive.rb +55 -51
  45. data/lib/net/ssh/connection/session.rb +620 -551
  46. data/lib/net/ssh/connection/term.rb +125 -123
  47. data/lib/net/ssh/errors.rb +101 -99
  48. data/lib/net/ssh/key_factory.rb +197 -105
  49. data/lib/net/ssh/known_hosts.rb +214 -127
  50. data/lib/net/ssh/loggable.rb +50 -49
  51. data/lib/net/ssh/packet.rb +83 -79
  52. data/lib/net/ssh/prompt.rb +50 -81
  53. data/lib/net/ssh/proxy/command.rb +105 -90
  54. data/lib/net/ssh/proxy/errors.rb +12 -10
  55. data/lib/net/ssh/proxy/http.rb +82 -79
  56. data/lib/net/ssh/proxy/https.rb +50 -0
  57. data/lib/net/ssh/proxy/jump.rb +54 -0
  58. data/lib/net/ssh/proxy/socks4.rb +2 -6
  59. data/lib/net/ssh/proxy/socks5.rb +14 -17
  60. data/lib/net/ssh/service/forward.rb +370 -317
  61. data/lib/net/ssh/test/channel.rb +145 -136
  62. data/lib/net/ssh/test/extensions.rb +131 -110
  63. data/lib/net/ssh/test/kex.rb +34 -32
  64. data/lib/net/ssh/test/local_packet.rb +46 -44
  65. data/lib/net/ssh/test/packet.rb +89 -70
  66. data/lib/net/ssh/test/remote_packet.rb +32 -30
  67. data/lib/net/ssh/test/script.rb +156 -142
  68. data/lib/net/ssh/test/socket.rb +49 -48
  69. data/lib/net/ssh/test.rb +82 -77
  70. data/lib/net/ssh/transport/algorithms.rb +441 -360
  71. data/lib/net/ssh/transport/cipher_factory.rb +96 -98
  72. data/lib/net/ssh/transport/constants.rb +32 -24
  73. data/lib/net/ssh/transport/ctr.rb +42 -22
  74. data/lib/net/ssh/transport/hmac/abstract.rb +81 -63
  75. data/lib/net/ssh/transport/hmac/md5.rb +0 -2
  76. data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
  77. data/lib/net/ssh/transport/hmac/none.rb +0 -2
  78. data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
  79. data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
  80. data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
  81. data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
  82. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
  83. data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  84. data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
  85. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
  86. data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  87. data/lib/net/ssh/transport/hmac.rb +14 -12
  88. data/lib/net/ssh/transport/identity_cipher.rb +54 -52
  89. data/lib/net/ssh/transport/kex/abstract.rb +130 -0
  90. data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  91. data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
  92. data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  93. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
  94. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
  95. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +119 -213
  96. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -61
  97. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
  98. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
  99. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
  100. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
  101. data/lib/net/ssh/transport/kex.rb +15 -12
  102. data/lib/net/ssh/transport/key_expander.rb +24 -20
  103. data/lib/net/ssh/transport/openssl.rb +161 -124
  104. data/lib/net/ssh/transport/packet_stream.rb +225 -185
  105. data/lib/net/ssh/transport/server_version.rb +55 -56
  106. data/lib/net/ssh/transport/session.rb +306 -255
  107. data/lib/net/ssh/transport/state.rb +178 -176
  108. data/lib/net/ssh/verifiers/accept_new.rb +33 -0
  109. data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
  110. data/lib/net/ssh/verifiers/always.rb +58 -0
  111. data/lib/net/ssh/verifiers/never.rb +19 -0
  112. data/lib/net/ssh/version.rb +55 -53
  113. data/lib/net/ssh.rb +110 -47
  114. data/net-ssh-public_cert.pem +18 -18
  115. data/net-ssh.gemspec +36 -205
  116. data/support/ssh_tunnel_bug.rb +5 -5
  117. data.tar.gz.sig +0 -0
  118. metadata +153 -118
  119. metadata.gz.sig +0 -0
  120. data/.travis.yml +0 -18
  121. data/README.rdoc +0 -182
  122. data/lib/net/ssh/authentication/agent/java_pageant.rb +0 -85
  123. data/lib/net/ssh/authentication/agent/socket.rb +0 -178
  124. data/lib/net/ssh/ruby_compat.rb +0 -46
  125. data/lib/net/ssh/verifiers/lenient.rb +0 -30
  126. data/lib/net/ssh/verifiers/null.rb +0 -12
  127. data/lib/net/ssh/verifiers/secure.rb +0 -52
  128. data/lib/net/ssh/verifiers/strict.rb +0 -24
  129. data/setup.rb +0 -1585
  130. data/support/arcfour_check.rb +0 -20
  131. data/test/README.txt +0 -18
  132. data/test/authentication/methods/common.rb +0 -28
  133. data/test/authentication/methods/test_abstract.rb +0 -51
  134. data/test/authentication/methods/test_hostbased.rb +0 -114
  135. data/test/authentication/methods/test_keyboard_interactive.rb +0 -121
  136. data/test/authentication/methods/test_none.rb +0 -41
  137. data/test/authentication/methods/test_password.rb +0 -95
  138. data/test/authentication/methods/test_publickey.rb +0 -148
  139. data/test/authentication/test_agent.rb +0 -232
  140. data/test/authentication/test_key_manager.rb +0 -240
  141. data/test/authentication/test_session.rb +0 -107
  142. data/test/common.rb +0 -125
  143. data/test/configs/auth_off +0 -5
  144. data/test/configs/auth_on +0 -4
  145. data/test/configs/empty +0 -0
  146. data/test/configs/eqsign +0 -3
  147. data/test/configs/exact_match +0 -8
  148. data/test/configs/host_plus +0 -10
  149. data/test/configs/multihost +0 -4
  150. data/test/configs/negative_match +0 -6
  151. data/test/configs/nohost +0 -19
  152. data/test/configs/numeric_host +0 -4
  153. data/test/configs/proxy_remote_user +0 -2
  154. data/test/configs/send_env +0 -2
  155. data/test/configs/substitutes +0 -8
  156. data/test/configs/wild_cards +0 -14
  157. data/test/connection/test_channel.rb +0 -487
  158. data/test/connection/test_session.rb +0 -564
  159. data/test/integration/README.txt +0 -17
  160. data/test/integration/Vagrantfile +0 -12
  161. data/test/integration/common.rb +0 -63
  162. data/test/integration/playbook.yml +0 -56
  163. data/test/integration/test_forward.rb +0 -637
  164. data/test/integration/test_id_rsa_keys.rb +0 -96
  165. data/test/integration/test_proxy.rb +0 -93
  166. data/test/known_hosts/github +0 -1
  167. data/test/known_hosts/github_hash +0 -1
  168. data/test/manual/test_pageant.rb +0 -37
  169. data/test/start/test_connection.rb +0 -53
  170. data/test/start/test_options.rb +0 -57
  171. data/test/start/test_transport.rb +0 -28
  172. data/test/start/test_user_nil.rb +0 -27
  173. data/test/test_all.rb +0 -12
  174. data/test/test_buffer.rb +0 -433
  175. data/test/test_buffered_io.rb +0 -63
  176. data/test/test_config.rb +0 -268
  177. data/test/test_key_factory.rb +0 -191
  178. data/test/test_known_hosts.rb +0 -66
  179. data/test/transport/hmac/test_md5.rb +0 -41
  180. data/test/transport/hmac/test_md5_96.rb +0 -27
  181. data/test/transport/hmac/test_none.rb +0 -34
  182. data/test/transport/hmac/test_ripemd160.rb +0 -36
  183. data/test/transport/hmac/test_sha1.rb +0 -36
  184. data/test/transport/hmac/test_sha1_96.rb +0 -27
  185. data/test/transport/hmac/test_sha2_256.rb +0 -37
  186. data/test/transport/hmac/test_sha2_256_96.rb +0 -27
  187. data/test/transport/hmac/test_sha2_512.rb +0 -37
  188. data/test/transport/hmac/test_sha2_512_96.rb +0 -27
  189. data/test/transport/kex/test_diffie_hellman_group14_sha1.rb +0 -13
  190. data/test/transport/kex/test_diffie_hellman_group1_sha1.rb +0 -150
  191. data/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +0 -96
  192. data/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +0 -19
  193. data/test/transport/kex/test_ecdh_sha2_nistp256.rb +0 -161
  194. data/test/transport/kex/test_ecdh_sha2_nistp384.rb +0 -38
  195. data/test/transport/kex/test_ecdh_sha2_nistp521.rb +0 -38
  196. data/test/transport/test_algorithms.rb +0 -328
  197. data/test/transport/test_cipher_factory.rb +0 -443
  198. data/test/transport/test_hmac.rb +0 -34
  199. data/test/transport/test_identity_cipher.rb +0 -40
  200. data/test/transport/test_packet_stream.rb +0 -1762
  201. data/test/transport/test_server_version.rb +0 -74
  202. data/test/transport/test_session.rb +0 -331
  203. data/test/transport/test_state.rb +0 -181
  204. data/test/verifiers/test_secure.rb +0 -40
data/CHANGES.txt CHANGED
@@ -1,12 +1,233 @@
1
- === 3.2.0
2
1
 
3
- * Added agent_socket_factory option [Alon Goldboim]
4
- * Send KEXINIT asap don't wait for server [Miklos Fazekas]
5
- * Close channels in case server closed connection [Miklos Fazekas]
2
+ === 7.1.0
6
3
 
7
- === 3.1.1
4
+ * Accept pubkey_algorithms option when starting a new connection [#891]
8
5
 
9
- * added missing etc require
6
+ === 7.1.0 beta1
7
+
8
+ * Don't use the deprecated set_XXX methods on RSA keys. [#875]
9
+ * Raise error when BCryptPbkdf fails [#876]
10
+
11
+ === 7.0.1
12
+
13
+ * Drop leftover debug statement [#866]
14
+
15
+ === 7.0.0
16
+
17
+ * BREAKING: Drop support for Ruby 2.5
18
+ * Fix decoding of ecdsa-sha2-nistp256 private keys [#657, #854]
19
+ * Fix missing require [#855]
20
+ * Support `~` in the path to the SSH agent's unix socket [#850]
21
+ * Add support for RSA client authentication with SHA-2 [a45f54]
22
+ * openssl: DSA: don't hardcode expected signature size, see ruby/openssl#483 [23a15c]
23
+ * Internal housekeeping (rubocop, codecov, remove travis, adding/improving tests)
24
+
25
+ === 6.3.0 beta1
26
+
27
+ * Support cert based host key auth, fix asterisk in known_hosts [#833]
28
+ * Support kex dh-group14-sha256 [#795]
29
+ * Fix StrictHostKeyChecking ssh config parameter translation [#765]
30
+
31
+ === 6.2.0 rc1
32
+
33
+ === 6.2.0 beta1
34
+
35
+ * rsa-sha2-512, rsa-sha2-256 host_key algs [#771]
36
+ * JRuby aes*-ctr suppport [#767]
37
+
38
+ === 6.1.0
39
+
40
+ * Adapt to ssh's default behaviors when no username is provided.
41
+ When Net::SSH.start user is nil and config has no entry
42
+ we default to Etc.getpwuid.name() instead of Etc.getlogin(). [#749]
43
+
44
+ === 6.1.0.rc1
45
+
46
+ * Make sha2-{256,512}-etm@openssh.com MAC default again [#761]
47
+ * Support algorithm subtraction syntax from ssh_config [#751]
48
+
49
+ === 6.0.2
50
+
51
+ * Fix corrupted hmac issue in etm hmac [#759]
52
+
53
+ === 6.0.1
54
+
55
+ * Make sha2-{256,512}-etm@openssh.com MAC opt-in as they seems to have issues [#757]
56
+
57
+ === 6.0.0
58
+
59
+ * Support empty lines and comments in known_hosts [donoghuc, #742]
60
+ * Add sha2-{256,512}-etm@openssh.com MAC algorithms [graaff, #714]
61
+
62
+ === 6.0.0 beta2
63
+
64
+ * Support :certkeys and CertificateFile configuration option [Anders Carling, #722]
65
+
66
+ === 6.0.0 beta1
67
+
68
+ * curve25519sha256 support [Florian Wininger ,#690]
69
+ * disabled insecure algs [Florian Wininger , #709]
70
+
71
+ === 5.2.0
72
+
73
+ === 5.2.0.rc3
74
+
75
+ * Fix check_host_ip read from config
76
+ * Support ssh-ed25519 in known hosts
77
+
78
+ === 5.2.0.rc2
79
+
80
+ * Read check_host_ip from ssh config files
81
+
82
+ === 5.2.0.rc1
83
+
84
+ * Interpret * and ? in know_hosts file [Romain Tartière, #660]
85
+ * New :check_host_ip so ip checking can be disabled in known hosts [Romain Tartière, #656]
86
+
87
+ === 5.1.0
88
+
89
+ === 5.1.0.rc1
90
+
91
+ * Support new OpenSSH private key format for rsa - bcrypt for rsa (ed25519 already supported) [#646]
92
+ * Support IdentityAgent is ssh config [Frank Groeneveld, #645]
93
+ * Improve Match processing in ssh config [Aleksandrs Ļedovskis, #642]
94
+ * Ignore signature verification when verify_host_key is never [Piotr Kliczewski, #641]
95
+ * Alg preference was changed to prefer stronger encryptions [Tray, #637]
96
+
97
+ === 5.0.2
98
+
99
+ * Fix ctr for jruby [#612]
100
+
101
+ === 5.0.1
102
+
103
+ * default_keys were not loaded even if no keys or key_data options specified [#607]
104
+
105
+ === 5.0.0
106
+
107
+ * Breaking change: ed25519 now requires ed25519 gem instead of RbNaCl gem [#563]
108
+ * Verify_host_key options rename (true, false, :very, :secure depreacted new equivalents are :never, :accept_new_or_local_tunnel :accept_new :always) [Jared Beck, #595]
109
+
110
+ === 5.0.0.rc2
111
+
112
+ * Add .dll extensions to dlopen on cygwin [#603]
113
+ * Fix host certificate validation [#601]
114
+
115
+ === 5.0.0.rc1
116
+
117
+ * Fix larger than 4GB file transfers [#599]
118
+ * Update HTTP proxy to version 1.1 [Connor Dunn, #597]
119
+
120
+ === 5.0.0.beta2
121
+
122
+ * Support for sha256 pubkey fingerprint [Tom Maher, #585]
123
+ * Don't try to load default_keys if key_data option is used [Josh Larson, #589]
124
+ * Added fingerprint_hash defaulting to SHA256 as fingerprint format, and MD5 can be used as an option [Miklós Fazekas, #591]
125
+
126
+ === 5.0.0.beta1
127
+
128
+ * Don't leave proxy command as zombie on timeout [DimitriosLisenko, #560]
129
+ * Use OpenSSL for aes*-ctr for up to 5x throughput improvement [Miklós Fazekas, Harald Sitter, #570]
130
+ * Optimize slice! usage in CTR for up to 2x throughput improvement [Harald Sitter, #569]
131
+ * Replace RbNaCl dependency with ed25519 gem [Tony Arcieri ,#563]
132
+ * Add initial Match support [Kasumi Hanazuki, #553]
133
+
134
+ === 4.2.0.rc2
135
+
136
+ * Fix double close bug on auth failure (or ruby 2.2 or earlier) [#538]
137
+
138
+ === 4.2.0.rc1
139
+
140
+ * Improved logging with proxy command [Dmitriy Ivliev, #530]
141
+ * Close transport on proxy error [adamruzicka, #526]
142
+ * Support multiple identity files [Kimura Masayuki, #528]
143
+ * Move `none` cipher to end of cipher list [Brian Cain, #525]
144
+ * Deprecate `:paranoid` in favor of `:verify_host_key` [Jared Beck, #524]
145
+ * Support Multile Include ssh config files [Kasumi Hanazuki, #516]
146
+ * Support Relative path in ssh confif files [Akinori MUSHA, #510]
147
+ * add direct-streamlocal@openssh.com support in Forward class [Harald Sitter, #502]
148
+
149
+ === 4.1.0
150
+ === 4.1.0.rc1
151
+
152
+ * ProxyJump support [Ryan McGeary, #500]
153
+ * Fix agent detection on Windows [Christian Koehler, #495]
154
+
155
+ === 4.1.0.beta1
156
+
157
+ * Fix nil error when libsodium is not there [chapmajs ,#488]
158
+ * SSH certificate support for client auth [David Bartley, #485]
159
+
160
+ === 4.0.1
161
+ === 4.0.1.rc2
162
+
163
+ * ENV["HOME"] might be empty so filter non expandable paths [Matt Casper, #351]
164
+
165
+ === 4.0.1.rc1
166
+
167
+ * support of rbnacl 4.0 and better error message [#479]
168
+ * support include in config files [Kimura Masayuki, #475]
169
+ * fixed issue with ruby 2.2 or older on windows [#472]
170
+
171
+ === 4.0.0
172
+ === 4.0.0.rc3
173
+
174
+ * parse `+` character in config files [Christoph Lupprich, #470, #314]
175
+
176
+ === 4.0.0.rc2
177
+
178
+ * Fixed OpenSSL 2.0/Ruby 2.4.0 warnings [Miklós Fazekas, #468]
179
+ * Added ssh-ed25519 to KnownHosts:SUPPORTED_TYPE [detatka-kuzlatka-otevrete, Miklós Fazekas, #459]
180
+ * Allow nil for :passhrase and passing in nil option is now a depreaction warning [Miklós Fazekas, #465]
181
+
182
+ === 4.0.0.rc1
183
+
184
+ * Allow :password to be nil for capistrano v2 compatibility [Will Bryant, #357]
185
+ * In next_packet if prefer consuming buffer before filling it again if we have enough data [Miklós Fazekas, #454]
186
+
187
+ === 4.0.0.beta4
188
+
189
+ * Added exitstatus method to exec's return [Miklós Fazekas, #452]
190
+ * Don't raise from exec if server closes transport just after channel close [Miklós Fazekas, #450]
191
+ * Removed java_pageant, as jruby should be using regular pagent impl [Miklós Fazekas, ]
192
+ * Use SSH_AUTH_SOCK if possible on windows (cygwin) [Miklós Fazekas, Martin Dürst, #365, #361]
193
+ * HTTPS proxy support [Marcus Ilgner, #432]
194
+ * Supports ruby 2.4.0.dev new exception type from OpenSSL::PKey.read
195
+
196
+ === 4.0.0.beta3
197
+
198
+ * Fix Net::SSH::Disconnect exceptions when channels are closed cleanly [Miklos Fazekas, #421, #422]
199
+
200
+ === 4.0.0.beta2
201
+
202
+ * Fix raiseUnlessLoaded undefined ERROR issue [Miklos Fazekas, #418]
203
+
204
+ === 4.0.0.beta1
205
+
206
+ * Fix pageant [elconas, #235]
207
+ * Relaxed rbnacl,rbnacl-selenium contstraints ang give better errors about them [Miklos Fazekas, #398]
208
+ * Fix UTF-8 encoding issues [Ethan J. Brown, #407]
209
+
210
+ === 4.0.0.alpha4
211
+
212
+ * Experimental event loop abstraction [Miklos Fazekas]
213
+ * RbNacl dependency is optional [Miklos Fazekas]
214
+ * agent_socket_factory option [Alon Goldboim]
215
+ * client sends KEXINIT, it doesn't have to wait for server [Miklos Fazekas]
216
+ * better error message when option is nil [Kane Morgan]
217
+ * prompting can be customized [Miklos Fazekas]
218
+
219
+ === 4.0.0.alpha3
220
+
221
+ * added max_select_wait_time [Eugene Kenny]
222
+
223
+ === 4.0.0.alpha2
224
+
225
+ * when transport closes we're cleaning up channels [Miklos Fazekas]
226
+
227
+ === 4.0.0.alpha1
228
+
229
+ * ed25519 key support [Miklos Fazekas]
230
+ * removed camellia [Miklos Fazekas]
10
231
 
11
232
  === 3.1.0
12
233
  === 3.1.0.rc1
@@ -95,7 +316,7 @@
95
316
  === 2.9.2-beta
96
317
 
97
318
  * Remove advertised algorithms that were not working (ssh-rsa-cert-* *ed25519 acm*-gcm@openssh.com) [mfazekas]
98
- * Unkown algorithms now ignored instead of failed [mfazekas]
319
+ * Unknown algorithms now ignored instead of failed [mfazekas]
99
320
  * Configuration change: Asks for password with password auth (up to number_of_password_prompts) [mfazekas]
100
321
  * Removed warnings [amatsuda]
101
322
 
data/Dockerfile ADDED
@@ -0,0 +1,27 @@
1
+ ARG RUBY_VERSION=3.1
2
+ FROM ruby:${RUBY_VERSION}
3
+
4
+ RUN apt update && apt install -y openssh-server sudo netcat \
5
+ && useradd --create-home --shell '/bin/bash' --comment 'NetSSH' 'net_ssh_1' \
6
+ && useradd --create-home --shell '/bin/bash' --comment 'NetSSH' 'net_ssh_2' \
7
+ && echo net_ssh_1:foopwd | chpasswd \
8
+ && echo net_ssh_2:foo2pwd | chpasswd \
9
+ && mkdir -p /home/net_ssh_1/.ssh \
10
+ && mkdir -p /home/net_ssh_2/.ssh \
11
+ && echo "net_ssh_1 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
12
+ && echo "net_ssh_2 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
13
+ && ssh-keygen -f /etc/ssh/users_ca -N ''
14
+
15
+ ENV INSTALL_PATH="/netssh"
16
+
17
+ WORKDIR $INSTALL_PATH
18
+
19
+ COPY Gemfile net-ssh.gemspec $INSTALL_PATH/
20
+
21
+ COPY lib/net/ssh/version.rb $INSTALL_PATH/lib/net/ssh/version.rb
22
+
23
+ RUN gem install bundler && bundle install
24
+
25
+ COPY . $INSTALL_PATH/
26
+
27
+ CMD service ssh start && rake test && NET_SSH_NO_ED25519=1 rake test
@@ -0,0 +1,17 @@
1
+ FROM ubuntu:22.04
2
+
3
+ ENV INSTALL_PATH="/netssh"
4
+
5
+ RUN apt update && apt install -y openssl ruby ruby-dev git build-essential
6
+
7
+ WORKDIR $INSTALL_PATH
8
+
9
+ COPY Gemfile net-ssh.gemspec $INSTALL_PATH/
10
+
11
+ COPY lib/net/ssh/version.rb $INSTALL_PATH/lib/net/ssh/version.rb
12
+
13
+ RUN ls -l && gem install bundler && bundle install
14
+
15
+ COPY . $INSTALL_PATH/
16
+
17
+ CMD openssl version && ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION' && rake test
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mygem.gemspec
4
+ gemspec
5
+
6
+ gem 'byebug', group: %i[development test] if !Gem.win_platform? && RUBY_ENGINE == "ruby"
7
+
8
+ if ENV["CI"]
9
+ gem 'codecov', require: false, group: :test
10
+ gem 'simplecov', require: false, group: :test
11
+ end
12
+
13
+ gem 'webrick', group: %i[development test] if RUBY_VERSION.split(".")[0].to_i >= 3
data/Gemfile.noed25519 ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ENV['NET_SSH_NO_ED25519'] = 'true'
4
+ # Specify your gem's dependencies in mygem.gemspec
5
+ gemspec
6
+
7
+ if ENV["CI"] && !Gem.win_platform?
8
+ gem 'simplecov', require: false, group: :test
9
+ gem 'codecov', require: false, group: :test
10
+ end
11
+
12
+ gem 'webrick', group: %i[development test] if RUBY_VERSION.split(".")[0].to_i >= 3
data/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,30 @@
1
+ ### Expected behavior
2
+
3
+ Tell us what should happen
4
+
5
+ ### Actual behavior
6
+
7
+ Tell us what happens instead.
8
+
9
+ ### System configuration
10
+
11
+ - net-ssh version
12
+ - Ruby version
13
+
14
+ ### Example App
15
+
16
+ Please provide an example script that reproduces the problem. This will save maintainers time so they can spend it fixing your issues instead of trying to build a reproduction case from sparse instructions.
17
+
18
+ You can use this as stating point:
19
+
20
+ ```ruby
21
+ gem 'net-ssh', '= 4.0.0.beta3'
22
+ require 'net/ssh'
23
+ puts Net::SSH::Version::CURRENT
24
+
25
+ @host = 'localhost'
26
+ @user = ENV['USER']
27
+ Net::SSH.start(@host, @user) do |ssh|
28
+ puts ssh.exec!('echo "hello"')
29
+ end
30
+ ```
data/Manifest CHANGED
@@ -33,7 +33,6 @@ lib/net/ssh/proxy/errors.rb
33
33
  lib/net/ssh/proxy/http.rb
34
34
  lib/net/ssh/proxy/socks4.rb
35
35
  lib/net/ssh/proxy/socks5.rb
36
- lib/net/ssh/ruby_compat.rb
37
36
  lib/net/ssh/service/forward.rb
38
37
  lib/net/ssh/test.rb
39
38
  lib/net/ssh/test/channel.rb
@@ -75,10 +74,10 @@ lib/net/ssh/transport/packet_stream.rb
75
74
  lib/net/ssh/transport/server_version.rb
76
75
  lib/net/ssh/transport/session.rb
77
76
  lib/net/ssh/transport/state.rb
78
- lib/net/ssh/verifiers/lenient.rb
79
- lib/net/ssh/verifiers/null.rb
80
- lib/net/ssh/verifiers/secure.rb
81
- lib/net/ssh/verifiers/strict.rb
77
+ lib/net/ssh/verifiers/accept_new.rb
78
+ lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb
79
+ lib/net/ssh/verifiers/always.rb
80
+ lib/net/ssh/verifiers/never.rb
82
81
  lib/net/ssh/version.rb
83
82
  net-ssh.gemspec
84
83
  setup.rb
data/README.md ADDED
@@ -0,0 +1,297 @@
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 7.*.
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 7.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 7.0 |
58
+ | diffie-hellman-group14-sha1 | OK | |
59
+ | diffie-hellman-group-exchange-sha1 | Deprecated in 6.0 | unsecure, will be removed in 7.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
+ | aes256-cbc / aes192-cbc / aes128-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
68
+ | rijndael-cbc@lysator.liu.se | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
69
+ | blowfish-ctr blowfish-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
70
+ | cast128-ctr cast128-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
71
+ | 3des-ctr 3des-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
72
+ | idea-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
73
+ | none | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
74
+
75
+ ### Message Authentication Code algorithms
76
+
77
+ | Name | Support | Details |
78
+ |----------------------|-----------------------|----------|
79
+ | hmac-sha2-512-etm | OK | |
80
+ | hmac-sha2-256-etm | OK | |
81
+ | hmac-sha2-512 | OK | |
82
+ | hmac-sha2-256 | OK | |
83
+ | hmac-sha2-512-96 | Deprecated in 6.0 | removed from the specification, will be removed in 7.0 |
84
+ | hmac-sha2-256-96 | Deprecated in 6.0 | removed from the specification, will be removed in 7.0 |
85
+ | hmac-sha1 | OK | for backward compatibility |
86
+ | hmac-sha1-96 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
87
+ | hmac-ripemd160 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
88
+ | hmac-md5 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
89
+ | hmac-md5-96 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
90
+ | none | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
91
+
92
+ ## SYNOPSIS:
93
+
94
+ In a nutshell:
95
+
96
+ ```ruby
97
+ require 'net/ssh'
98
+
99
+ Net::SSH.start('host', 'user', password: "password") do |ssh|
100
+
101
+ # capture all stderr and stdout output from a remote process
102
+ output = ssh.exec!("hostname")
103
+ puts output
104
+
105
+ # capture only stdout matching a particular pattern
106
+ stdout = ""
107
+ ssh.exec!("ls -l /home/jamis") do |channel, stream, data|
108
+ stdout << data if stream == :stdout && /foo/.match(data)
109
+ end
110
+ puts stdout
111
+
112
+ # run multiple processes in parallel to completion
113
+ ssh.exec "sed ..."
114
+ ssh.exec "awk ..."
115
+ ssh.exec "rm -rf ..."
116
+ ssh.loop
117
+
118
+ # open a new channel and configure a minimal set of callbacks, then run
119
+ # the event loop until the channel finishes (closes)
120
+ channel = ssh.open_channel do |ch|
121
+ ch.exec "/usr/local/bin/ruby /path/to/file.rb" do |ch, success|
122
+ raise "could not execute command" unless success
123
+
124
+ # "on_data" is called when the process writes something to stdout
125
+ ch.on_data do |c, data|
126
+ $stdout.print data
127
+ end
128
+
129
+ # "on_extended_data" is called when the process writes something to stderr
130
+ ch.on_extended_data do |c, type, data|
131
+ $stderr.print data
132
+ end
133
+
134
+ ch.on_close { puts "done!" }
135
+ end
136
+ end
137
+
138
+ channel.wait
139
+
140
+ # forward connections on local port 1234 to port 80 of www.capify.org
141
+ ssh.forward.local(1234, "www.capify.org", 80)
142
+ ssh.loop { true }
143
+ end
144
+ ```
145
+
146
+ See Net::SSH for more documentation, and links to further information.
147
+
148
+ ## REQUIREMENTS:
149
+
150
+ The only requirement you might be missing is the OpenSSL bindings for Ruby with a version greather than `1.0.1`.
151
+ 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:
152
+
153
+ ```sh
154
+ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
155
+ ```
156
+
157
+ If that spits out something like `OpenSSL 1.0.1 14 Mar 2012`, then you're set.
158
+ If you get an error, then you'll need to see about rebuilding ruby with OpenSSL support,
159
+ or (if your platform supports it) installing the OpenSSL bindings separately.
160
+
161
+ ## INSTALL:
162
+
163
+ ```sh
164
+ gem install net-ssh # might need sudo privileges
165
+ ```
166
+
167
+ NOTE: If you are running on jruby on windows you need to install `jruby-pageant` manually
168
+ (gemspec doesn't allow for platform specific dependencies at gem installation time).
169
+
170
+ However, in order to be sure the code you're installing hasn't been tampered with,
171
+ it's recommended that you verify the [signature](http://docs.rubygems.org/read/chapter/21).
172
+ To do this, you need to add my public key as a trusted certificate (you only need to do this once):
173
+
174
+ ```sh
175
+ # Add the public key as a trusted certificate
176
+ # (You only need to do this once)
177
+ curl -O https://raw.githubusercontent.com/net-ssh/net-ssh/master/net-ssh-public_cert.pem
178
+ gem cert --add net-ssh-public_cert.pem
179
+ ```
180
+
181
+ Then, when install the gem, do so with high security:
182
+
183
+ ```sh
184
+ gem install net-ssh -P HighSecurity
185
+ ```
186
+
187
+ If you don't add the public key, you'll see an error like "Couldn't verify data signature".
188
+ If you're still having trouble let me know and I'll give you a hand.
189
+
190
+ For ed25519 public key auth support your bundle file should contain `ed25519`, `bcrypt_pbkdf` dependencies.
191
+
192
+ ```sh
193
+ gem install ed25519
194
+ gem install bcrypt_pbkdf
195
+ ```
196
+
197
+ For curve25519-sha256 kex exchange support your bundle file should contain `x25519` dependency.
198
+
199
+ ## RUBY SUPPORT
200
+
201
+ * See [net-ssh.gemspec](https://github.com/net-ssh/net-ssh/blob/master/net-ssh.gemspec) for current versions ruby requirements
202
+
203
+ ## RUNNING TESTS
204
+
205
+ If you want to run the tests or use any of the Rake tasks, you'll need Mocha and
206
+ other dependencies listed in Gemfile
207
+
208
+ Run the test suite from the net-ssh directory with the following command:
209
+
210
+ ```sh
211
+ bundle exec rake test
212
+ ```
213
+
214
+ NOTE : you can run test on all ruby versions with docker :
215
+
216
+ ```
217
+ docker-compose up --build
218
+ ```
219
+
220
+ Run a single test file like this:
221
+
222
+ ```sh
223
+ ruby -Ilib -Itest test/transport/test_server_version.rb
224
+ ```
225
+
226
+ To run integration tests see [here](test/integration/README.md)
227
+
228
+ ### BUILDING GEM
229
+
230
+ ```sh
231
+ rake build
232
+ ```
233
+
234
+ ### GEM SIGNING (for maintainers)
235
+
236
+ 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:
237
+
238
+ ```sh
239
+ NET_SSH_BUILDGEM_SIGNED=true rake build
240
+ ```
241
+
242
+ For time to time, the public certificate associated to the private key needs to be renewed. You can do this with the following command:
243
+
244
+ ```sh
245
+ gem cert --build netssh@solutious.com --private-key path/2/net-ssh-private_key.pem
246
+ mv gem-public_cert.pem net-ssh-public_cert.pem
247
+ gem cert --add net-ssh-public_cert.pem
248
+ ```
249
+
250
+ ## Security contact information
251
+
252
+ See [SECURITY.md](SECURITY.md)
253
+
254
+ ## CREDITS
255
+
256
+ ### Contributors
257
+
258
+ This project exists thanks to all the people who contribute.
259
+
260
+ [![contributors](https://opencollective.com/net-ssh/contributors.svg?width=890&button=false)](graphs/contributors)
261
+
262
+ ### Backers
263
+
264
+ Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/net-ssh#backer)
265
+
266
+ [![backers](https://opencollective.com/net-ssh/backers.svg?width=890)](https://opencollective.com/net-ssh#backers)
267
+
268
+ ### Sponsors
269
+
270
+ 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)
271
+
272
+ [![Sponsor](https://opencollective.com/net-ssh/sponsor/0/avatar.svg)](https://opencollective.com/net-ssh/sponsor/0/website)
273
+
274
+ ## LICENSE:
275
+
276
+ (The MIT License)
277
+
278
+ Copyright (c) 2008 Jamis Buck
279
+
280
+ Permission is hereby granted, free of charge, to any person obtaining
281
+ a copy of this software and associated documentation files (the
282
+ 'Software'), to deal in the Software without restriction, including
283
+ without limitation the rights to use, copy, modify, merge, publish,
284
+ distribute, sublicense, and/or sell copies of the Software, and to
285
+ permit persons to whom the Software is furnished to do so, subject to
286
+ the following conditions:
287
+
288
+ The above copyright notice and this permission notice shall be
289
+ included in all copies or substantial portions of the Software.
290
+
291
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
292
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
293
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
294
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
295
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
296
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
297
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.