net-ssh-backports 6.3.0.backports

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 (111) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +93 -0
  3. data/.gitignore +13 -0
  4. data/.rubocop.yml +21 -0
  5. data/.rubocop_todo.yml +1074 -0
  6. data/.travis.yml +51 -0
  7. data/CHANGES.txt +698 -0
  8. data/Gemfile +13 -0
  9. data/Gemfile.noed25519 +12 -0
  10. data/ISSUE_TEMPLATE.md +30 -0
  11. data/LICENSE.txt +19 -0
  12. data/Manifest +132 -0
  13. data/README.md +287 -0
  14. data/Rakefile +105 -0
  15. data/THANKS.txt +110 -0
  16. data/appveyor.yml +58 -0
  17. data/lib/net/ssh/authentication/agent.rb +284 -0
  18. data/lib/net/ssh/authentication/certificate.rb +183 -0
  19. data/lib/net/ssh/authentication/constants.rb +20 -0
  20. data/lib/net/ssh/authentication/ed25519.rb +185 -0
  21. data/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
  22. data/lib/net/ssh/authentication/key_manager.rb +297 -0
  23. data/lib/net/ssh/authentication/methods/abstract.rb +69 -0
  24. data/lib/net/ssh/authentication/methods/hostbased.rb +72 -0
  25. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +77 -0
  26. data/lib/net/ssh/authentication/methods/none.rb +34 -0
  27. data/lib/net/ssh/authentication/methods/password.rb +80 -0
  28. data/lib/net/ssh/authentication/methods/publickey.rb +95 -0
  29. data/lib/net/ssh/authentication/pageant.rb +497 -0
  30. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  31. data/lib/net/ssh/authentication/session.rb +163 -0
  32. data/lib/net/ssh/buffer.rb +434 -0
  33. data/lib/net/ssh/buffered_io.rb +202 -0
  34. data/lib/net/ssh/config.rb +406 -0
  35. data/lib/net/ssh/connection/channel.rb +695 -0
  36. data/lib/net/ssh/connection/constants.rb +33 -0
  37. data/lib/net/ssh/connection/event_loop.rb +123 -0
  38. data/lib/net/ssh/connection/keepalive.rb +59 -0
  39. data/lib/net/ssh/connection/session.rb +712 -0
  40. data/lib/net/ssh/connection/term.rb +180 -0
  41. data/lib/net/ssh/errors.rb +106 -0
  42. data/lib/net/ssh/key_factory.rb +218 -0
  43. data/lib/net/ssh/known_hosts.rb +264 -0
  44. data/lib/net/ssh/loggable.rb +62 -0
  45. data/lib/net/ssh/packet.rb +106 -0
  46. data/lib/net/ssh/prompt.rb +62 -0
  47. data/lib/net/ssh/proxy/command.rb +123 -0
  48. data/lib/net/ssh/proxy/errors.rb +16 -0
  49. data/lib/net/ssh/proxy/http.rb +98 -0
  50. data/lib/net/ssh/proxy/https.rb +50 -0
  51. data/lib/net/ssh/proxy/jump.rb +54 -0
  52. data/lib/net/ssh/proxy/socks4.rb +67 -0
  53. data/lib/net/ssh/proxy/socks5.rb +140 -0
  54. data/lib/net/ssh/service/forward.rb +426 -0
  55. data/lib/net/ssh/test/channel.rb +147 -0
  56. data/lib/net/ssh/test/extensions.rb +173 -0
  57. data/lib/net/ssh/test/kex.rb +46 -0
  58. data/lib/net/ssh/test/local_packet.rb +53 -0
  59. data/lib/net/ssh/test/packet.rb +101 -0
  60. data/lib/net/ssh/test/remote_packet.rb +40 -0
  61. data/lib/net/ssh/test/script.rb +180 -0
  62. data/lib/net/ssh/test/socket.rb +65 -0
  63. data/lib/net/ssh/test.rb +94 -0
  64. data/lib/net/ssh/transport/algorithms.rb +502 -0
  65. data/lib/net/ssh/transport/cipher_factory.rb +103 -0
  66. data/lib/net/ssh/transport/constants.rb +40 -0
  67. data/lib/net/ssh/transport/ctr.rb +115 -0
  68. data/lib/net/ssh/transport/hmac/abstract.rb +97 -0
  69. data/lib/net/ssh/transport/hmac/md5.rb +10 -0
  70. data/lib/net/ssh/transport/hmac/md5_96.rb +9 -0
  71. data/lib/net/ssh/transport/hmac/none.rb +13 -0
  72. data/lib/net/ssh/transport/hmac/ripemd160.rb +11 -0
  73. data/lib/net/ssh/transport/hmac/sha1.rb +11 -0
  74. data/lib/net/ssh/transport/hmac/sha1_96.rb +9 -0
  75. data/lib/net/ssh/transport/hmac/sha2_256.rb +11 -0
  76. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +9 -0
  77. data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  78. data/lib/net/ssh/transport/hmac/sha2_512.rb +11 -0
  79. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +9 -0
  80. data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  81. data/lib/net/ssh/transport/hmac.rb +47 -0
  82. data/lib/net/ssh/transport/identity_cipher.rb +57 -0
  83. data/lib/net/ssh/transport/kex/abstract.rb +130 -0
  84. data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  85. data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
  86. data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  87. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +37 -0
  88. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
  89. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +122 -0
  90. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +72 -0
  91. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +11 -0
  92. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +39 -0
  93. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +21 -0
  94. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +21 -0
  95. data/lib/net/ssh/transport/kex.rb +31 -0
  96. data/lib/net/ssh/transport/key_expander.rb +30 -0
  97. data/lib/net/ssh/transport/openssl.rb +253 -0
  98. data/lib/net/ssh/transport/packet_stream.rb +280 -0
  99. data/lib/net/ssh/transport/server_version.rb +77 -0
  100. data/lib/net/ssh/transport/session.rb +354 -0
  101. data/lib/net/ssh/transport/state.rb +208 -0
  102. data/lib/net/ssh/verifiers/accept_new.rb +33 -0
  103. data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
  104. data/lib/net/ssh/verifiers/always.rb +58 -0
  105. data/lib/net/ssh/verifiers/never.rb +19 -0
  106. data/lib/net/ssh/version.rb +68 -0
  107. data/lib/net/ssh.rb +330 -0
  108. data/net-ssh-public_cert.pem +20 -0
  109. data/net-ssh.gemspec +44 -0
  110. data/support/ssh_tunnel_bug.rb +65 -0
  111. metadata +271 -0
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/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright © 2008 Jamis Buck
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the ‘Software’), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,132 @@
1
+ CHANGELOG.rdoc
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ Rudyfile
6
+ THANKS.rdoc
7
+ lib/net/ssh.rb
8
+ lib/net/ssh/authentication/agent.rb
9
+ lib/net/ssh/authentication/constants.rb
10
+ lib/net/ssh/authentication/key_manager.rb
11
+ lib/net/ssh/authentication/methods/abstract.rb
12
+ lib/net/ssh/authentication/methods/hostbased.rb
13
+ lib/net/ssh/authentication/methods/keyboard_interactive.rb
14
+ lib/net/ssh/authentication/methods/password.rb
15
+ lib/net/ssh/authentication/methods/publickey.rb
16
+ lib/net/ssh/authentication/pageant.rb
17
+ lib/net/ssh/authentication/session.rb
18
+ lib/net/ssh/buffer.rb
19
+ lib/net/ssh/buffered_io.rb
20
+ lib/net/ssh/config.rb
21
+ lib/net/ssh/connection/channel.rb
22
+ lib/net/ssh/connection/constants.rb
23
+ lib/net/ssh/connection/session.rb
24
+ lib/net/ssh/connection/term.rb
25
+ lib/net/ssh/errors.rb
26
+ lib/net/ssh/key_factory.rb
27
+ lib/net/ssh/known_hosts.rb
28
+ lib/net/ssh/loggable.rb
29
+ lib/net/ssh/packet.rb
30
+ lib/net/ssh/prompt.rb
31
+ lib/net/ssh/proxy/command.rb
32
+ lib/net/ssh/proxy/errors.rb
33
+ lib/net/ssh/proxy/http.rb
34
+ lib/net/ssh/proxy/socks4.rb
35
+ lib/net/ssh/proxy/socks5.rb
36
+ lib/net/ssh/service/forward.rb
37
+ lib/net/ssh/test.rb
38
+ lib/net/ssh/test/channel.rb
39
+ lib/net/ssh/test/extensions.rb
40
+ lib/net/ssh/test/kex.rb
41
+ lib/net/ssh/test/local_packet.rb
42
+ lib/net/ssh/test/packet.rb
43
+ lib/net/ssh/test/remote_packet.rb
44
+ lib/net/ssh/test/script.rb
45
+ lib/net/ssh/test/socket.rb
46
+ lib/net/ssh/transport/algorithms.rb
47
+ lib/net/ssh/transport/cipher_factory.rb
48
+ lib/net/ssh/transport/constants.rb
49
+ lib/net/ssh/transport/ctr.rb
50
+ lib/net/ssh/transport/hmac.rb
51
+ lib/net/ssh/transport/hmac/abstract.rb
52
+ lib/net/ssh/transport/hmac/md5.rb
53
+ lib/net/ssh/transport/hmac/md5_96.rb
54
+ lib/net/ssh/transport/hmac/none.rb
55
+ lib/net/ssh/transport/hmac/ripemd160.rb
56
+ lib/net/ssh/transport/hmac/sha1.rb
57
+ lib/net/ssh/transport/hmac/sha1_96.rb
58
+ lib/net/ssh/transport/hmac/sha2_256.rb
59
+ lib/net/ssh/transport/hmac/sha2_256_96.rb
60
+ lib/net/ssh/transport/hmac/sha2_512.rb
61
+ lib/net/ssh/transport/hmac/sha2_512_96.rb
62
+ lib/net/ssh/transport/identity_cipher.rb
63
+ lib/net/ssh/transport/key_expander.rb
64
+ lib/net/ssh/transport/kex.rb
65
+ lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
66
+ lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb
67
+ lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb
68
+ lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb
69
+ lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb
70
+ lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb
71
+ lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb
72
+ lib/net/ssh/transport/openssl.rb
73
+ lib/net/ssh/transport/packet_stream.rb
74
+ lib/net/ssh/transport/server_version.rb
75
+ lib/net/ssh/transport/session.rb
76
+ lib/net/ssh/transport/state.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
81
+ lib/net/ssh/version.rb
82
+ net-ssh.gemspec
83
+ setup.rb
84
+ support/arcfour_check.rb
85
+ support/ssh_tunnel_bug.rb
86
+ test/authentication/methods/common.rb
87
+ test/authentication/methods/test_abstract.rb
88
+ test/authentication/methods/test_hostbased.rb
89
+ test/authentication/methods/test_keyboard_interactive.rb
90
+ test/authentication/methods/test_password.rb
91
+ test/authentication/methods/test_publickey.rb
92
+ test/authentication/test_agent.rb
93
+ test/authentication/test_key_manager.rb
94
+ test/authentication/test_session.rb
95
+ test/common.rb
96
+ test/configs/eqsign
97
+ test/configs/exact_match
98
+ test/configs/host_plus
99
+ test/configs/multihost
100
+ test/configs/wild_cards
101
+ test/connection/test_channel.rb
102
+ test/connection/test_session.rb
103
+ test/test_all.rb
104
+ test/test_buffer.rb
105
+ test/test_buffered_io.rb
106
+ test/test_config.rb
107
+ test/test_key_factory.rb
108
+ test/transport/hmac/test_md5.rb
109
+ test/transport/hmac/test_md5_96.rb
110
+ test/transport/hmac/test_none.rb
111
+ test/transport/hmac/test_ripemd160.rb
112
+ test/transport/hmac/test_sha1.rb
113
+ test/transport/hmac/test_sha1_96.rb
114
+ test/transport/hmac/test_sha2_256.rb
115
+ test/transport/hmac/test_sha2_256_96.rb
116
+ test/transport/hmac/test_sha2_512.rb
117
+ test/transport/hmac/test_sha2_512_96.rb
118
+ test/transport/kex/test_diffie_hellman_group1_sha1.rb
119
+ test/transport/kex/test_diffie_hellman_group14_sha1.rb
120
+ test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
121
+ test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb
122
+ test/transport/kex/test_ecdh_sha2_nistp256.rb
123
+ test/transport/kex/test_ecdh_sha2_nistp384.rb
124
+ test/transport/kex/test_ecdh_sha2_nistp521.rb
125
+ test/transport/test_algorithms.rb
126
+ test/transport/test_cipher_factory.rb
127
+ test/transport/test_hmac.rb
128
+ test/transport/test_identity_cipher.rb
129
+ test/transport/test_packet_stream.rb
130
+ test/transport/test_server_version.rb
131
+ test/transport/test_session.rb
132
+ test/transport/test_state.rb
data/README.md ADDED
@@ -0,0 +1,287 @@
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 6.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
+ Run a single test file like this:
215
+
216
+ ```sh
217
+ ruby -Ilib -Itest test/transport/test_server_version.rb
218
+ ```
219
+
220
+ To run integration tests see test/integration/README.txt
221
+
222
+ ### BUILDING GEM
223
+
224
+ ```sh
225
+ rake build
226
+ ```
227
+
228
+ ### GEM SIGNING (for maintainers)
229
+
230
+ 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:
231
+
232
+ ```sh
233
+ NET_SSH_BUILDGEM_SIGNED=true rake build
234
+ ```
235
+
236
+ For time to time, the public certificate associated to the private key needs to be renewed. You can do this with the following command:
237
+
238
+ ```sh
239
+ gem cert --build netssh@solutious.com --private-key path/2/net-ssh-private_key.pem
240
+ mv gem-public_cert.pem net-ssh-public_cert.pem
241
+ gem cert --add net-ssh-public_cert.pem
242
+ ```
243
+
244
+ ## CREDITS
245
+
246
+ ### Contributors
247
+
248
+ This project exists thanks to all the people who contribute.
249
+
250
+ [![contributors](https://opencollective.com/net-ssh/contributors.svg?width=890&button=false)](graphs/contributors)
251
+
252
+ ### Backers
253
+
254
+ Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/net-ssh#backer)
255
+
256
+ [![backers](https://opencollective.com/net-ssh/backers.svg?width=890)](https://opencollective.com/net-ssh#backers)
257
+
258
+ ### Sponsors
259
+
260
+ 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)
261
+
262
+ [![Sponsor](https://opencollective.com/net-ssh/sponsor/0/avatar.svg)](https://opencollective.com/net-ssh/sponsor/0/website)
263
+
264
+ ## LICENSE:
265
+
266
+ (The MIT License)
267
+
268
+ Copyright (c) 2008 Jamis Buck
269
+
270
+ Permission is hereby granted, free of charge, to any person obtaining
271
+ a copy of this software and associated documentation files (the
272
+ 'Software'), to deal in the Software without restriction, including
273
+ without limitation the rights to use, copy, modify, merge, publish,
274
+ distribute, sublicense, and/or sell copies of the Software, and to
275
+ permit persons to whom the Software is furnished to do so, subject to
276
+ the following conditions:
277
+
278
+ The above copyright notice and this permission notice shall be
279
+ included in all copies or substantial portions of the Software.
280
+
281
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
282
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
283
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
284
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
285
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
286
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
287
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,105 @@
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
+
7
+ require "rubygems"
8
+ require "rake"
9
+ require "rake/clean"
10
+ require "bundler/gem_tasks"
11
+
12
+ require "rdoc/task"
13
+
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']
24
+ name = "net-ssh"
25
+
26
+ require_relative "lib/net/ssh/version"
27
+ version = Net::SSH::Version::CURRENT
28
+
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
+ namespace :rdoc do
59
+ desc "Update gh-pages branch"
60
+ task :publish do
61
+ # copy/checkout
62
+ rm_rf "/tmp/net-ssh-rdoc"
63
+ rm_rf "/tmp/net-ssh-gh-pages"
64
+ cp_r "./rdoc", "/tmp/net-ssh-rdoc"
65
+ mkdir "/tmp/net-ssh-gh-pages"
66
+ Dir.chdir "/tmp/net-ssh-gh-pages" do
67
+ sh "git clone --branch gh-pages --single-branch https://github.com/net-ssh/net-ssh"
68
+ rm_rf "/tmp/net-ssh-gh-pages/net-ssh/*"
69
+ end
70
+ # update
71
+ sh "cp -rf ./rdoc/* /tmp/net-ssh-gh-pages/net-ssh/"
72
+ Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
73
+ sh "git add -A ."
74
+ sh "git commit -m \"Update docs\""
75
+ end
76
+ # publish
77
+ Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
78
+ sh "git push origin gh-pages"
79
+ end
80
+ end
81
+ end
82
+
83
+ require 'rake/testtask'
84
+
85
+ Rake::TestTask.new do |t|
86
+ t.libs = ["lib", "test"]
87
+ t.libs << "test/integration" if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
88
+ t.libs << "test/win_integration" if ENV['NET_SSH_RUN_WIN_INTEGRATION_TESTS']
89
+ test_files = FileList['test/**/test_*.rb']
90
+ test_files -= FileList['test/integration/**/test_*.rb'] unless ENV['NET_SSH_RUN_INTEGRATION_TESTS']
91
+ test_files -= FileList['test/win_integration/**/test_*.rb'] unless ENV['NET_SSH_RUN_WIN_INTEGRATION_TESTS']
92
+ test_files -= FileList['test/manual/test_*.rb']
93
+ test_files -= FileList['test/test_pageant.rb']
94
+ test_files -= FileList['test/test/**/test_*.rb']
95
+ t.test_files = test_files
96
+ end
97
+
98
+ desc "Run tests of Net::SSH:Test"
99
+ Rake::TestTask.new do |t|
100
+ t.name = "test_test"
101
+ # we need to run test/test separatedly as it hacks io + other modules
102
+ t.libs = ["lib", "test"]
103
+ test_files = FileList['test/test/**/test_*.rb']
104
+ t.test_files = test_files
105
+ end