net-ssh 4.2.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  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 +13 -0
  8. data/.gitignore +7 -0
  9. data/.rubocop.yml +19 -2
  10. data/.rubocop_todo.yml +619 -667
  11. data/CHANGES.txt +110 -1
  12. data/Dockerfile +27 -0
  13. data/Dockerfile.openssl3 +17 -0
  14. data/Gemfile +3 -7
  15. data/{Gemfile.norbnacl → Gemfile.noed25519} +3 -1
  16. data/Manifest +4 -5
  17. data/README.md +293 -0
  18. data/Rakefile +45 -29
  19. data/appveyor.yml +8 -6
  20. data/docker-compose.yml +23 -0
  21. data/lib/net/ssh/authentication/agent.rb +248 -223
  22. data/lib/net/ssh/authentication/certificate.rb +178 -164
  23. data/lib/net/ssh/authentication/constants.rb +17 -15
  24. data/lib/net/ssh/authentication/ed25519.rb +141 -116
  25. data/lib/net/ssh/authentication/ed25519_loader.rb +28 -28
  26. data/lib/net/ssh/authentication/key_manager.rb +79 -36
  27. data/lib/net/ssh/authentication/methods/abstract.rb +62 -47
  28. data/lib/net/ssh/authentication/methods/hostbased.rb +34 -37
  29. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +3 -3
  30. data/lib/net/ssh/authentication/methods/none.rb +16 -19
  31. data/lib/net/ssh/authentication/methods/password.rb +15 -16
  32. data/lib/net/ssh/authentication/methods/publickey.rb +96 -55
  33. data/lib/net/ssh/authentication/pageant.rb +468 -465
  34. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  35. data/lib/net/ssh/authentication/session.rb +131 -122
  36. data/lib/net/ssh/buffer.rb +385 -332
  37. data/lib/net/ssh/buffered_io.rb +150 -151
  38. data/lib/net/ssh/config.rb +316 -239
  39. data/lib/net/ssh/connection/channel.rb +635 -613
  40. data/lib/net/ssh/connection/constants.rb +29 -29
  41. data/lib/net/ssh/connection/event_loop.rb +104 -95
  42. data/lib/net/ssh/connection/keepalive.rb +55 -51
  43. data/lib/net/ssh/connection/session.rb +614 -611
  44. data/lib/net/ssh/connection/term.rb +125 -123
  45. data/lib/net/ssh/errors.rb +101 -99
  46. data/lib/net/ssh/key_factory.rb +194 -108
  47. data/lib/net/ssh/known_hosts.rb +212 -134
  48. data/lib/net/ssh/loggable.rb +50 -49
  49. data/lib/net/ssh/packet.rb +83 -79
  50. data/lib/net/ssh/prompt.rb +51 -51
  51. data/lib/net/ssh/proxy/command.rb +105 -91
  52. data/lib/net/ssh/proxy/errors.rb +12 -10
  53. data/lib/net/ssh/proxy/http.rb +81 -81
  54. data/lib/net/ssh/proxy/https.rb +37 -36
  55. data/lib/net/ssh/proxy/jump.rb +49 -48
  56. data/lib/net/ssh/proxy/socks4.rb +2 -6
  57. data/lib/net/ssh/proxy/socks5.rb +14 -17
  58. data/lib/net/ssh/service/forward.rb +365 -362
  59. data/lib/net/ssh/test/channel.rb +145 -143
  60. data/lib/net/ssh/test/extensions.rb +131 -127
  61. data/lib/net/ssh/test/kex.rb +34 -32
  62. data/lib/net/ssh/test/local_packet.rb +46 -44
  63. data/lib/net/ssh/test/packet.rb +87 -84
  64. data/lib/net/ssh/test/remote_packet.rb +32 -30
  65. data/lib/net/ssh/test/script.rb +155 -155
  66. data/lib/net/ssh/test/socket.rb +49 -48
  67. data/lib/net/ssh/test.rb +82 -80
  68. data/lib/net/ssh/transport/algorithms.rb +433 -364
  69. data/lib/net/ssh/transport/cipher_factory.rb +95 -91
  70. data/lib/net/ssh/transport/constants.rb +32 -24
  71. data/lib/net/ssh/transport/ctr.rb +37 -15
  72. data/lib/net/ssh/transport/hmac/abstract.rb +81 -63
  73. data/lib/net/ssh/transport/hmac/md5.rb +0 -2
  74. data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
  75. data/lib/net/ssh/transport/hmac/none.rb +0 -2
  76. data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
  77. data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
  78. data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
  79. data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
  80. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
  81. data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  82. data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
  83. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
  84. data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  85. data/lib/net/ssh/transport/hmac.rb +14 -12
  86. data/lib/net/ssh/transport/identity_cipher.rb +54 -52
  87. data/lib/net/ssh/transport/kex/abstract.rb +130 -0
  88. data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  89. data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
  90. data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  91. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
  92. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
  93. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +112 -217
  94. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -63
  95. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
  96. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
  97. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
  98. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
  99. data/lib/net/ssh/transport/kex.rb +15 -12
  100. data/lib/net/ssh/transport/key_expander.rb +24 -21
  101. data/lib/net/ssh/transport/openssl.rb +158 -133
  102. data/lib/net/ssh/transport/packet_stream.rb +223 -191
  103. data/lib/net/ssh/transport/server_version.rb +55 -56
  104. data/lib/net/ssh/transport/session.rb +306 -259
  105. data/lib/net/ssh/transport/state.rb +178 -176
  106. data/lib/net/ssh/verifiers/accept_new.rb +33 -0
  107. data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
  108. data/lib/net/ssh/verifiers/always.rb +58 -0
  109. data/lib/net/ssh/verifiers/never.rb +19 -0
  110. data/lib/net/ssh/version.rb +55 -53
  111. data/lib/net/ssh.rb +47 -34
  112. data/net-ssh-public_cert.pem +18 -19
  113. data/net-ssh.gemspec +12 -11
  114. data/support/ssh_tunnel_bug.rb +5 -5
  115. data.tar.gz.sig +0 -0
  116. metadata +78 -73
  117. metadata.gz.sig +0 -0
  118. data/.travis.yml +0 -51
  119. data/Gemfile.norbnacl.lock +0 -41
  120. data/README.rdoc +0 -169
  121. data/lib/net/ssh/ruby_compat.rb +0 -24
  122. data/lib/net/ssh/verifiers/lenient.rb +0 -30
  123. data/lib/net/ssh/verifiers/null.rb +0 -12
  124. data/lib/net/ssh/verifiers/secure.rb +0 -52
  125. data/lib/net/ssh/verifiers/strict.rb +0 -24
  126. data/support/arcfour_check.rb +0 -20
data/CHANGES.txt CHANGED
@@ -1,3 +1,112 @@
1
+ === 6.3.0 beta1
2
+
3
+ * Support cert based host key auth, fix asterisk in known_hosts [#833]
4
+ * Support kex dh-group14-sha256 [#795]
5
+ * Fix StrictHostKeyChecking ssh config parameter translation [#765]
6
+
7
+ === 6.2.0 rc1
8
+
9
+ === 6.2.0 beta1
10
+
11
+ * rsa-sha2-512, rsa-sha2-256 host_key algs [#771]
12
+ * JRuby aes*-ctr suppport [#767]
13
+
14
+ === 6.1.0
15
+
16
+ * Adapt to ssh's default behaviors when no username is provided.
17
+ When Net::SSH.start user is nil and config has no entry
18
+ we default to Etc.getpwuid.name() instead of Etc.getlogin(). [#749]
19
+
20
+ === 6.1.0.rc1
21
+
22
+ * Make sha2-{256,512}-etm@openssh.com MAC default again [#761]
23
+ * Support algorithm subtraction syntax from ssh_config [#751]
24
+
25
+ === 6.0.2
26
+
27
+ * Fix corrupted hmac issue in etm hmac [#759]
28
+
29
+ === 6.0.1
30
+
31
+ * Make sha2-{256,512}-etm@openssh.com MAC opt-in as they seems to have issues [#757]
32
+
33
+ === 6.0.0
34
+
35
+ * Support empty lines and comments in known_hosts [donoghuc, #742]
36
+ * Add sha2-{256,512}-etm@openssh.com MAC algorithms [graaff, #714]
37
+
38
+ === 6.0.0 beta2
39
+
40
+ * Support :certkeys and CertificateFile configuration option [Anders Carling, #722]
41
+
42
+ === 6.0.0 beta1
43
+
44
+ * curve25519sha256 support [Florian Wininger ,#690]
45
+ * disabled insecure algs [Florian Wininger , #709]
46
+
47
+ === 5.2.0
48
+
49
+ === 5.2.0.rc3
50
+
51
+ * Fix check_host_ip read from config
52
+ * Support ssh-ed25519 in known hosts
53
+
54
+ === 5.2.0.rc2
55
+
56
+ * Read check_host_ip from ssh config files
57
+
58
+ === 5.2.0.rc1
59
+
60
+ * Interpret * and ? in know_hosts file [Romain Tartière, #660]
61
+ * New :check_host_ip so ip checking can be disabled in known hosts [Romain Tartière, #656]
62
+
63
+ === 5.1.0
64
+
65
+ === 5.1.0.rc1
66
+
67
+ * Support new OpenSSH private key format for rsa - bcrypt for rsa (ed25519 already supported) [#646]
68
+ * Support IdentityAgent is ssh config [Frank Groeneveld, #645]
69
+ * Improve Match processing in ssh config [Aleksandrs Ļedovskis, #642]
70
+ * Ignore signature verification when verify_host_key is never [Piotr Kliczewski, #641]
71
+ * Alg preference was changed to prefer stronger encryptions [Tray, #637]
72
+
73
+ === 5.0.2
74
+
75
+ * Fix ctr for jruby [#612]
76
+
77
+ === 5.0.1
78
+
79
+ * default_keys were not loaded even if no keys or key_data options specified [#607]
80
+
81
+ === 5.0.0
82
+
83
+ * Breaking change: ed25519 now requires ed25519 gem instead of RbNaCl gem [#563]
84
+ * 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]
85
+
86
+ === 5.0.0.rc2
87
+
88
+ * Add .dll extensions to dlopen on cygwin [#603]
89
+ * Fix host certificate validation [#601]
90
+
91
+ === 5.0.0.rc1
92
+
93
+ * Fix larger than 4GB file transfers [#599]
94
+ * Update HTTP proxy to version 1.1 [Connor Dunn, #597]
95
+
96
+ === 5.0.0.beta2
97
+
98
+ * Support for sha256 pubkey fingerprint [Tom Maher, #585]
99
+ * Don't try to load default_keys if key_data option is used [Josh Larson, #589]
100
+ * Added fingerprint_hash defaulting to SHA256 as fingerprint format, and MD5 can be used as an option [Miklós Fazekas, #591]
101
+
102
+ === 5.0.0.beta1
103
+
104
+ * Don't leave proxy command as zombie on timeout [DimitriosLisenko, #560]
105
+ * Use OpenSSL for aes*-ctr for up to 5x throughput improvement [Miklós Fazekas, Harald Sitter, #570]
106
+ * Optimize slice! usage in CTR for up to 2x throughput improvement [Harald Sitter, #569]
107
+ * Replace RbNaCl dependency with ed25519 gem [Tony Arcieri ,#563]
108
+ * Add initial Match support [Kasumi Hanazuki, #553]
109
+
1
110
  === 4.2.0.rc2
2
111
 
3
112
  * Fix double close bug on auth failure (or ruby 2.2 or earlier) [#538]
@@ -183,7 +292,7 @@
183
292
  === 2.9.2-beta
184
293
 
185
294
  * Remove advertised algorithms that were not working (ssh-rsa-cert-* *ed25519 acm*-gcm@openssh.com) [mfazekas]
186
- * Unkown algorithms now ignored instead of failed [mfazekas]
295
+ * Unknown algorithms now ignored instead of failed [mfazekas]
187
296
  * Configuration change: Asks for password with password auth (up to number_of_password_prompts) [mfazekas]
188
297
  * Removed warnings [amatsuda]
189
298
 
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 CHANGED
@@ -3,15 +3,11 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in mygem.gemspec
4
4
  gemspec
5
5
 
6
- if !Gem.win_platform? && RUBY_ENGINE == "ruby"
7
- gem 'byebug', group: [:development, :test]
8
- end
9
-
10
- if (Gem::Version.new(RUBY_VERSION) <=> Gem::Version.new("2.2.6")) < 0
11
- gem 'rbnacl', '< 4.0'
12
- end
6
+ gem 'byebug', group: %i[development test] if !Gem.win_platform? && RUBY_ENGINE == "ruby"
13
7
 
14
8
  if ENV["CI"]
15
9
  gem 'codecov', require: false, group: :test
16
10
  gem 'simplecov', require: false, group: :test
17
11
  end
12
+
13
+ gem 'webrick', group: %i[development test] if RUBY_VERSION.split(".")[0].to_i >= 3
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ENV['NET_SSH_NO_RBNACL'] = 'true'
3
+ ENV['NET_SSH_NO_ED25519'] = 'true'
4
4
  # Specify your gem's dependencies in mygem.gemspec
5
5
  gemspec
6
6
 
@@ -8,3 +8,5 @@ if ENV["CI"] && !Gem.win_platform?
8
8
  gem 'simplecov', require: false, group: :test
9
9
  gem 'codecov', require: false, group: :test
10
10
  end
11
+
12
+ gem 'webrick', group: %i[development test] if RUBY_VERSION.split(".")[0].to_i >= 3
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,293 @@
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
+ 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
+ ## CREDITS
251
+
252
+ ### Contributors
253
+
254
+ This project exists thanks to all the people who contribute.
255
+
256
+ [![contributors](https://opencollective.com/net-ssh/contributors.svg?width=890&button=false)](graphs/contributors)
257
+
258
+ ### Backers
259
+
260
+ Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/net-ssh#backer)
261
+
262
+ [![backers](https://opencollective.com/net-ssh/backers.svg?width=890)](https://opencollective.com/net-ssh#backers)
263
+
264
+ ### Sponsors
265
+
266
+ 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)
267
+
268
+ [![Sponsor](https://opencollective.com/net-ssh/sponsor/0/avatar.svg)](https://opencollective.com/net-ssh/sponsor/0/website)
269
+
270
+ ## LICENSE:
271
+
272
+ (The MIT License)
273
+
274
+ Copyright (c) 2008 Jamis Buck
275
+
276
+ Permission is hereby granted, free of charge, to any person obtaining
277
+ a copy of this software and associated documentation files (the
278
+ 'Software'), to deal in the Software without restriction, including
279
+ without limitation the rights to use, copy, modify, merge, publish,
280
+ distribute, sublicense, and/or sell copies of the Software, and to
281
+ permit persons to whom the Software is furnished to do so, subject to
282
+ the following conditions:
283
+
284
+ The above copyright notice and this permission notice shall be
285
+ included in all copies or substantial portions of the Software.
286
+
287
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
288
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
289
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
290
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
291
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
292
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
293
+ 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
@@ -12,7 +11,6 @@ require "bundler/gem_tasks"
12
11
 
13
12
  require "rdoc/task"
14
13
 
15
-
16
14
  desc "When releasing make sure NET_SSH_BUILDGEM_SIGNED is set"
17
15
  task :check_NET_SSH_BUILDGEM_SIGNED do
18
16
  raise "NET_SSH_BUILDGEM_SIGNED should be set to release" unless ENV['NET_SSH_BUILDGEM_SIGNED']
@@ -21,9 +19,8 @@ end
21
19
  Rake::Task[:release].enhance [:check_NET_SSH_BUILDGEM_SIGNED]
22
20
  Rake::Task[:release].prerequisites.unshift(:check_NET_SSH_BUILDGEM_SIGNED)
23
21
 
24
-
25
22
  task default: ["build"]
26
- CLEAN.include [ 'pkg', 'rdoc' ]
23
+ CLEAN.include ['pkg', 'rdoc']
27
24
  name = "net-ssh"
28
25
 
29
26
  require_relative "lib/net/ssh/version"
@@ -34,38 +31,53 @@ RDoc::Task.new do |rdoc|
34
31
  rdoc.rdoc_dir = "rdoc"
35
32
  rdoc.title = "#{name} #{version}"
36
33
  rdoc.generator = 'hanna' # gem install hanna-nouveau
37
- rdoc.main = 'README.rdoc'
34
+ rdoc.main = 'README.md'
38
35
  rdoc.rdoc_files.include("README*")
39
36
  rdoc.rdoc_files.include("bin/*.rb")
40
37
  rdoc.rdoc_files.include("lib/**/*.rb")
41
38
  extra_files.each { |file|
42
- rdoc.rdoc_files.include(file) if File.exists?(file)
39
+ rdoc.rdoc_files.include(file) if File.exist?(file)
43
40
  }
44
41
  end
45
42
 
46
- namespace :rdoc do
47
- desc "Update gh-pages branch"
48
- task :publish do
49
- # copy/checkout
50
- rm_rf "/tmp/net-ssh-rdoc"
51
- rm_rf "/tmp/net-ssh-gh-pages"
52
- cp_r "./rdoc", "/tmp/net-ssh-rdoc"
53
- mkdir "/tmp/net-ssh-gh-pages"
54
- Dir.chdir "/tmp/net-ssh-gh-pages" do
55
- sh "git clone --branch gh-pages --single-branch https://github.com/net-ssh/net-ssh"
56
- rm_rf "/tmp/net-ssh-gh-pages/net-ssh/*"
57
- end
58
- # update
59
- sh "cp -rf ./rdoc/* /tmp/net-ssh-gh-pages/net-ssh/"
60
- Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
61
- sh "git add -A ."
62
- sh "git commit -m \"Update docs\""
63
- end
64
- # publish
65
- Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
66
- sh "git push origin gh-pages"
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"
67
55
  end
68
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
69
81
  end
70
82
 
71
83
  require 'rake/testtask'
@@ -80,14 +92,18 @@ Rake::TestTask.new do |t|
80
92
  test_files -= FileList['test/manual/test_*.rb']
81
93
  test_files -= FileList['test/test_pageant.rb']
82
94
  test_files -= FileList['test/test/**/test_*.rb']
83
- t.test_files = test_files
95
+ t.test_files = test_files
84
96
  end
85
97
 
98
+ # We need to enable the OpenSSL 3.0 legacy providers for our test suite
99
+ require 'openssl'
100
+ ENV['OPENSSL_CONF'] = 'test/openssl3.conf' if OpenSSL::OPENSSL_LIBRARY_VERSION.start_with? "OpenSSL 3"
101
+
86
102
  desc "Run tests of Net::SSH:Test"
87
103
  Rake::TestTask.new do |t|
88
104
  t.name = "test_test"
89
105
  # we need to run test/test separatedly as it hacks io + other modules
90
106
  t.libs = ["lib", "test"]
91
107
  test_files = FileList['test/test/**/test_*.rb']
92
- t.test_files = test_files
108
+ t.test_files = test_files
93
109
  end
data/appveyor.yml CHANGED
@@ -5,9 +5,11 @@ skip_tags: true
5
5
  environment:
6
6
  matrix:
7
7
  - ruby_version: "jruby-9.1.2.0"
8
+ - ruby_version: "26-x64"
9
+ - ruby_version: "25-x64"
10
+ - ruby_version: "24-x64"
8
11
  - ruby_version: "23"
9
12
  - ruby_version: "23-x64"
10
- - ruby_version: "22-x64"
11
13
 
12
14
  matrix:
13
15
  allow_failures:
@@ -29,9 +31,9 @@ install:
29
31
  - if "%ruby_version%" == "jruby-9.1.2.0" ( cinst jruby --version 9.1.2.0 -i --allow-empty-checksums )
30
32
  - if "%ruby_version%" == "jruby-9.1.2.0" ( SET "PATH=C:\jruby-9.1.2.0\bin\;%PATH%" )
31
33
  - ruby --version
32
- - gem install bundler --no-document -v 1.13.5
33
- - SET BUNDLE_GEMFILE=Gemfile.norbnacl
34
- - bundle _1.13.5_ install --retry=3
34
+ - gem install bundler --no-document --user-install -v 1.17
35
+ - SET BUNDLE_GEMFILE=Gemfile.noed25519
36
+ - bundle install --retry=3
35
37
  - cinst freesshd
36
38
  - cinst putty --allow-empty-checksums
37
39
  - ps: |
@@ -49,8 +51,8 @@ install:
49
51
  }
50
52
 
51
53
  test_script:
52
- - SET BUNDLE_GEMFILE=Gemfile.norbnacl
54
+ - SET BUNDLE_GEMFILE=Gemfile.noed25519
53
55
  - SET NET_SSH_RUN_WIN_INTEGRATION_TESTS=YES
54
- - bundle _1.13.5_ exec rake test
56
+ - bundle exec rake test
55
57
 
56
58
  build: off