net-ssh 4.1.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +5 -0
  5. data/.rubocop.yml +8 -2
  6. data/.rubocop_todo.yml +405 -552
  7. data/.travis.yml +23 -22
  8. data/CHANGES.txt +112 -1
  9. data/Gemfile +1 -7
  10. data/{Gemfile.norbnacl → Gemfile.noed25519} +1 -1
  11. data/Manifest +4 -5
  12. data/README.md +287 -0
  13. data/Rakefile +40 -29
  14. data/appveyor.yml +12 -6
  15. data/lib/net/ssh.rb +68 -32
  16. data/lib/net/ssh/authentication/agent.rb +234 -222
  17. data/lib/net/ssh/authentication/certificate.rb +175 -164
  18. data/lib/net/ssh/authentication/constants.rb +17 -14
  19. data/lib/net/ssh/authentication/ed25519.rb +162 -141
  20. data/lib/net/ssh/authentication/ed25519_loader.rb +32 -29
  21. data/lib/net/ssh/authentication/key_manager.rb +40 -9
  22. data/lib/net/ssh/authentication/methods/abstract.rb +53 -47
  23. data/lib/net/ssh/authentication/methods/hostbased.rb +32 -33
  24. data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +1 -1
  25. data/lib/net/ssh/authentication/methods/none.rb +10 -10
  26. data/lib/net/ssh/authentication/methods/password.rb +13 -13
  27. data/lib/net/ssh/authentication/methods/publickey.rb +56 -55
  28. data/lib/net/ssh/authentication/pageant.rb +468 -465
  29. data/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  30. data/lib/net/ssh/authentication/session.rb +130 -122
  31. data/lib/net/ssh/buffer.rb +345 -312
  32. data/lib/net/ssh/buffered_io.rb +163 -163
  33. data/lib/net/ssh/config.rb +316 -238
  34. data/lib/net/ssh/connection/channel.rb +670 -650
  35. data/lib/net/ssh/connection/constants.rb +30 -26
  36. data/lib/net/ssh/connection/event_loop.rb +108 -105
  37. data/lib/net/ssh/connection/keepalive.rb +54 -50
  38. data/lib/net/ssh/connection/session.rb +682 -671
  39. data/lib/net/ssh/connection/term.rb +180 -176
  40. data/lib/net/ssh/errors.rb +101 -99
  41. data/lib/net/ssh/key_factory.rb +195 -108
  42. data/lib/net/ssh/known_hosts.rb +161 -152
  43. data/lib/net/ssh/loggable.rb +57 -55
  44. data/lib/net/ssh/packet.rb +82 -78
  45. data/lib/net/ssh/prompt.rb +55 -53
  46. data/lib/net/ssh/proxy/command.rb +104 -89
  47. data/lib/net/ssh/proxy/errors.rb +12 -8
  48. data/lib/net/ssh/proxy/http.rb +93 -91
  49. data/lib/net/ssh/proxy/https.rb +42 -39
  50. data/lib/net/ssh/proxy/jump.rb +50 -47
  51. data/lib/net/ssh/proxy/socks4.rb +0 -2
  52. data/lib/net/ssh/proxy/socks5.rb +11 -12
  53. data/lib/net/ssh/service/forward.rb +370 -317
  54. data/lib/net/ssh/test.rb +83 -77
  55. data/lib/net/ssh/test/channel.rb +146 -142
  56. data/lib/net/ssh/test/extensions.rb +150 -146
  57. data/lib/net/ssh/test/kex.rb +35 -31
  58. data/lib/net/ssh/test/local_packet.rb +48 -44
  59. data/lib/net/ssh/test/packet.rb +87 -84
  60. data/lib/net/ssh/test/remote_packet.rb +35 -31
  61. data/lib/net/ssh/test/script.rb +173 -171
  62. data/lib/net/ssh/test/socket.rb +59 -55
  63. data/lib/net/ssh/transport/algorithms.rb +430 -364
  64. data/lib/net/ssh/transport/cipher_factory.rb +95 -91
  65. data/lib/net/ssh/transport/constants.rb +33 -25
  66. data/lib/net/ssh/transport/ctr.rb +33 -11
  67. data/lib/net/ssh/transport/hmac.rb +15 -13
  68. data/lib/net/ssh/transport/hmac/abstract.rb +82 -63
  69. data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
  70. data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
  71. data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  72. data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
  73. data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
  74. data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  75. data/lib/net/ssh/transport/identity_cipher.rb +55 -51
  76. data/lib/net/ssh/transport/kex.rb +14 -13
  77. data/lib/net/ssh/transport/kex/abstract.rb +123 -0
  78. data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  79. data/lib/net/ssh/transport/kex/curve25519_sha256.rb +38 -0
  80. data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  81. data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +33 -40
  82. data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +112 -217
  83. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +53 -62
  84. data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
  85. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +36 -90
  86. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +18 -10
  87. data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +18 -10
  88. data/lib/net/ssh/transport/key_expander.rb +29 -25
  89. data/lib/net/ssh/transport/openssl.rb +116 -116
  90. data/lib/net/ssh/transport/packet_stream.rb +223 -190
  91. data/lib/net/ssh/transport/server_version.rb +64 -66
  92. data/lib/net/ssh/transport/session.rb +306 -257
  93. data/lib/net/ssh/transport/state.rb +198 -196
  94. data/lib/net/ssh/verifiers/accept_new.rb +35 -0
  95. data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +34 -0
  96. data/lib/net/ssh/verifiers/always.rb +56 -0
  97. data/lib/net/ssh/verifiers/never.rb +21 -0
  98. data/lib/net/ssh/version.rb +55 -53
  99. data/net-ssh-public_cert.pem +18 -19
  100. data/net-ssh.gemspec +12 -11
  101. data/support/ssh_tunnel_bug.rb +2 -2
  102. metadata +86 -75
  103. metadata.gz.sig +0 -0
  104. data/Gemfile.norbnacl.lock +0 -41
  105. data/README.rdoc +0 -169
  106. data/lib/net/ssh/ruby_compat.rb +0 -24
  107. data/lib/net/ssh/verifiers/lenient.rb +0 -30
  108. data/lib/net/ssh/verifiers/null.rb +0 -12
  109. data/lib/net/ssh/verifiers/secure.rb +0 -52
  110. data/lib/net/ssh/verifiers/strict.rb +0 -24
  111. data/support/arcfour_check.rb +0 -20
metadata.gz.sig CHANGED
Binary file
@@ -1,41 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- net-ssh (4.0.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.3.0)
10
- metaclass (0.0.4)
11
- minitest (5.10.1)
12
- mocha (1.2.1)
13
- metaclass (~> 0.0.1)
14
- parser (2.3.3.1)
15
- ast (~> 2.2)
16
- powerpack (0.1.1)
17
- rainbow (2.1.0)
18
- rake (12.0.0)
19
- rubocop (0.46.0)
20
- parser (>= 2.3.1.1, < 3.0)
21
- powerpack (~> 0.1)
22
- rainbow (>= 1.99.1, < 3.0)
23
- ruby-progressbar (~> 1.7)
24
- unicode-display_width (~> 1.0, >= 1.0.1)
25
- ruby-progressbar (1.8.1)
26
- unicode-display_width (1.1.2)
27
-
28
- PLATFORMS
29
- ruby
30
- x86-mingw32
31
-
32
- DEPENDENCIES
33
- bundler (~> 1.11)
34
- minitest (~> 5.10)
35
- mocha (>= 1.2.1)
36
- net-ssh!
37
- rake (~> 12.0)
38
- rubocop (~> 0.46.0)
39
-
40
- BUNDLED WITH
41
- 1.13.6
@@ -1,169 +0,0 @@
1
- {<img src="https://badge.fury.io/rb/net-ssh.svg" alt="Gem Version" />}[https://badge.fury.io/rb/net-ssh]
2
- {<img src="https://badges.gitter.im/net-ssh/net-ssh.svg" alt="Join the chat at https://gitter.im/net-ssh/net-ssh">}[https://gitter.im/net-ssh/net-ssh?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
3
- {<img src="https://travis-ci.org/net-ssh/net-ssh.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/net-ssh/net-ssh]
4
- {<img src="https://codecov.io/gh/net-ssh/net-ssh/branch/master/graph/badge.svg" alt="Coverage status" />}[https://codecov.io/gh/net-ssh/net-ssh]
5
-
6
- = Net::SSH 4.x
7
-
8
- * Docs: http://net-ssh.github.com/net-ssh
9
- * Issues: https://github.com/net-ssh/net-ssh/issues
10
- * Codes: https://github.com/net-ssh/net-ssh
11
- * Email: net-ssh@solutious.com
12
-
13
- <em>As of v2.6.4, all gem releases are signed. See INSTALL.</em>
14
-
15
- == DESCRIPTION:
16
-
17
- Net::SSH is a pure-Ruby implementation of the SSH2 client protocol. It allows you to write programs that invoke and interact with processes on remote servers, via SSH2.
18
-
19
- == FEATURES:
20
-
21
- * Execute processes on remote servers and capture their output
22
- * Run multiple processes in parallel over a single SSH connection
23
- * Support for SSH subsystems
24
- * Forward local and remote ports via an SSH connection
25
-
26
- == SYNOPSIS:
27
-
28
- In a nutshell:
29
-
30
- require 'net/ssh'
31
-
32
- Net::SSH.start('host', 'user', :password => "password") do |ssh|
33
- # capture all stderr and stdout output from a remote process
34
- output = ssh.exec!("hostname")
35
- puts output
36
-
37
- # capture only stdout matching a particular pattern
38
- stdout = ""
39
- ssh.exec!("ls -l /home/jamis") do |channel, stream, data|
40
- stdout << data if stream == :stdout
41
- end
42
- puts stdout
43
-
44
- # run multiple processes in parallel to completion
45
- ssh.exec "sed ..."
46
- ssh.exec "awk ..."
47
- ssh.exec "rm -rf ..."
48
- ssh.loop
49
-
50
- # open a new channel and configure a minimal set of callbacks, then run
51
- # the event loop until the channel finishes (closes)
52
- channel = ssh.open_channel do |ch|
53
- ch.exec "/usr/local/bin/ruby /path/to/file.rb" do |ch, success|
54
- raise "could not execute command" unless success
55
-
56
- # "on_data" is called when the process writes something to stdout
57
- ch.on_data do |c, data|
58
- $stdout.print data
59
- end
60
-
61
- # "on_extended_data" is called when the process writes something to stderr
62
- ch.on_extended_data do |c, type, data|
63
- $stderr.print data
64
- end
65
-
66
- ch.on_close { puts "done!" }
67
- end
68
- end
69
-
70
- channel.wait
71
-
72
- # forward connections on local port 1234 to port 80 of www.capify.org
73
- ssh.forward.local(1234, "www.capify.org", 80)
74
- ssh.loop { true }
75
- end
76
-
77
- See Net::SSH for more documentation, and links to further information.
78
-
79
- == REQUIREMENTS:
80
-
81
- The only requirement you might be missing is the OpenSSL bindings for Ruby. 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:
82
-
83
- ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
84
-
85
- If that spits out something like "OpenSSL 0.9.8g 19 Oct 2007", then you're set. If you get an error, then you'll need to see about rebuilding ruby with OpenSSL support, or (if your platform supports it) installing the OpenSSL bindings separately.
86
-
87
- Lastly, if you want to run the tests or use any of the Rake tasks, you'll need Mocha and other dependencies listed in Gemfile
88
-
89
-
90
- == INSTALL:
91
-
92
- * gem install net-ssh (might need sudo privileges)
93
-
94
- NOTE: If you are running on jruby on windows you need to install jruby-pageant manually (gemspec doesn't allow for platform specific dependencies).
95
-
96
- However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signature[http://docs.rubygems.org/read/chapter/21]. To do this, you need to add my public key as a trusted certificate (you only need to do this once):
97
-
98
- # Add the public key as a trusted certificate
99
- # (You only need to do this once)
100
- $ curl -O https://raw.githubusercontent.com/net-ssh/net-ssh/master/net-ssh-public_cert.pem
101
- $ gem cert --add net-ssh-public_cert.pem
102
-
103
- Then, when install the gem, do so with high security:
104
-
105
- $ gem install net-ssh -P HighSecurity
106
-
107
- If you don't add the public key, you'll see an error like "Couldn't verify data signature". If you're still having trouble let me know and I'll give you a hand.
108
-
109
- For ed25519 public key auth support your bundle file should contain ```rbnacl-libsodium```, ```rbnacl```, ```bcrypt_pbkdf``` dependencies.
110
-
111
- == RUBY SUPPORT
112
-
113
- * Ruby 1.8.x is supported up until the net-ssh 2.5.1 release.
114
- * Ruby 1.9.x is supported up until the net-ssh 2.9.x release.
115
- * Current net-ssh releases require Ruby 2.0 or later.
116
-
117
- == RUNNING TESTS
118
-
119
- Run the test suite from the net-ssh directory with the following command:
120
-
121
- bundle exec rake test
122
-
123
- Run a single test file like this:
124
-
125
- ruby -Ilib -Itest test/transport/test_server_version.rb
126
-
127
- To run integration tests see test/integration/README.txt
128
-
129
- === BUILDING GEM
130
-
131
- rake build
132
-
133
- === GEM SIGNING (for maintainers)
134
-
135
- 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:
136
-
137
- NET_SSH_BUILDGEM_SIGNED=true rake build
138
-
139
- For time to time, the public certificate associated to the private key needs to be renewed. You can do this with the following command:
140
-
141
- gem cert --build netssh@solutious.com --private-key path/2/net-ssh-private_key.pem
142
- mv gem-public_cert.pem net-ssh-public_cert.pem
143
- gem cert --add net-ssh-public_cert.pem
144
-
145
-
146
- == LICENSE:
147
-
148
- (The MIT License)
149
-
150
- Copyright (c) 2008 Jamis Buck
151
-
152
- Permission is hereby granted, free of charge, to any person obtaining
153
- a copy of this software and associated documentation files (the
154
- 'Software'), to deal in the Software without restriction, including
155
- without limitation the rights to use, copy, modify, merge, publish,
156
- distribute, sublicense, and/or sell copies of the Software, and to
157
- permit persons to whom the Software is furnished to do so, subject to
158
- the following conditions:
159
-
160
- The above copyright notice and this permission notice shall be
161
- included in all copies or substantial portions of the Software.
162
-
163
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
164
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
165
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
166
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
167
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
168
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
169
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,24 +0,0 @@
1
- require 'thread'
2
-
3
- class String
4
- if RUBY_VERSION < "1.9"
5
- def getbyte(index)
6
- self[index]
7
- end
8
- def setbyte(index, c)
9
- self[index] = c
10
- end
11
- end
12
- end
13
-
14
- module Net; module SSH
15
-
16
- # This class contains miscellaneous patches and workarounds
17
- # for different ruby implementations.
18
- class Compat
19
- def self.io_select(*params)
20
- IO.select(*params)
21
- end
22
- end
23
-
24
- end; end
@@ -1,30 +0,0 @@
1
- require 'net/ssh/verifiers/strict'
2
-
3
- module Net; module SSH; module Verifiers
4
-
5
- # Basically the same as the Strict verifier, but does not try to actually
6
- # verify a connection if the server is the localhost and the port is a
7
- # nonstandard port number. Those two conditions will typically mean the
8
- # connection is being tunnelled through a forwarded port, so the known-hosts
9
- # file will not be helpful (in general).
10
- class Lenient < Strict
11
- # Tries to determine if the connection is being tunnelled, and if so,
12
- # returns true. Otherwise, performs the standard strict verification.
13
- def verify(arguments)
14
- return true if tunnelled?(arguments)
15
- super
16
- end
17
-
18
- private
19
-
20
- # A connection is potentially being tunnelled if the port is not 22,
21
- # and the ip refers to the localhost.
22
- def tunnelled?(args)
23
- return false if args[:session].port == Net::SSH::Transport::Session::DEFAULT_PORT
24
-
25
- ip = args[:session].peer[:ip]
26
- return ip == "127.0.0.1" || ip == "::1"
27
- end
28
- end
29
-
30
- end; end; end
@@ -1,12 +0,0 @@
1
- module Net; module SSH; module Verifiers
2
-
3
- # The Null host key verifier simply allows every key it sees, without
4
- # bothering to verify. This is simple, but is not particularly secure.
5
- class Null
6
- # Returns true.
7
- def verify(arguments)
8
- true
9
- end
10
- end
11
-
12
- end; end; end
@@ -1,52 +0,0 @@
1
- require 'net/ssh/errors'
2
- require 'net/ssh/known_hosts'
3
-
4
- module Net; module SSH; module Verifiers
5
-
6
- # Does a strict host verification, looking the server up in the known
7
- # host files to see if a key has already been seen for this server. If this
8
- # server does not appear in any host file, an exception will be raised
9
- # (HostKeyUnknown). This is in contrast to the "Strict" class, which will
10
- # silently add the key to your known_hosts file. If the server does appear at
11
- # least once, but the key given does not match any known for the server, an
12
- # exception will be raised (HostKeyMismatch).
13
- # Otherwise, this returns true.
14
- class Secure
15
- def verify(arguments)
16
- host_keys = arguments[:session].host_keys
17
-
18
- # We've never seen this host before, so raise an exception.
19
- if host_keys.empty?
20
- process_cache_miss(host_keys, arguments, HostKeyUnknown, "is unknown")
21
- end
22
-
23
- # If we found any matches, check to see that the key type and
24
- # blob also match.
25
- found = host_keys.any? do |key|
26
- key.ssh_type == arguments[:key].ssh_type &&
27
- key.to_blob == arguments[:key].to_blob
28
- end
29
-
30
- # If a match was found, return true. Otherwise, raise an exception
31
- # indicating that the key was not recognized.
32
- unless found
33
- process_cache_miss(host_keys, arguments, HostKeyMismatch, "does not match")
34
- end
35
-
36
- found
37
- end
38
-
39
- private
40
-
41
- def process_cache_miss(host_keys, args, exc_class, message)
42
- exception = exc_class.new("fingerprint #{args[:fingerprint]} " +
43
- "#{message} for #{host_keys.host.inspect}")
44
- exception.data = args
45
- exception.callback = Proc.new do
46
- host_keys.add_host_key(args[:key])
47
- end
48
- raise exception
49
- end
50
- end
51
-
52
- end; end; end
@@ -1,24 +0,0 @@
1
- require 'net/ssh/errors'
2
- require 'net/ssh/known_hosts'
3
- require 'net/ssh/verifiers/secure'
4
-
5
- module Net; module SSH; module Verifiers
6
-
7
- # Does a strict host verification, looking the server up in the known
8
- # host files to see if a key has already been seen for this server. If this
9
- # server does not appear in any host file, this will silently add the
10
- # server. If the server does appear at least once, but the key given does
11
- # not match any known for the server, an exception will be raised (HostKeyMismatch).
12
- # Otherwise, this returns true.
13
- class Strict < Secure
14
- def verify(arguments)
15
- begin
16
- super
17
- rescue HostKeyUnknown => err
18
- err.remember_host!
19
- return true
20
- end
21
- end
22
- end
23
-
24
- end; end; end
@@ -1,20 +0,0 @@
1
-
2
- require 'net/ssh'
3
-
4
- # ARCFOUR CHECK
5
- #
6
- # Usage:
7
- # $ ruby support/arcfour_check.rb
8
- #
9
- # Expected Output:
10
- # arcfour128: [16, 8] OpenSSL::Cipher::Cipher
11
- # arcfour256: [32, 8] OpenSSL::Cipher::Cipher
12
- # arcfour512: [64, 8] OpenSSL::Cipher::Cipher
13
-
14
- [['arcfour128', 16], ['arcfour256', 32], ['arcfour512', 64]].each do |cipher|
15
- print "#{cipher[0]}: "
16
- a = Net::SSH::Transport::CipherFactory.get_lengths(cipher[0])
17
- b = Net::SSH::Transport::CipherFactory.get(cipher[0], key: ([].fill('x', 0, cipher[1]).join))
18
- puts "#{a} #{b.class}"
19
- end
20
-