mega-sharp-pkg 0.0.1

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 (120) hide show
  1. checksums.yaml +7 -0
  2. data/mega-sharp-pkg.gemspec +11 -0
  3. data/net-ssh-7.3.3/CHANGES.txt +764 -0
  4. data/net-ssh-7.3.3/DEVELOPMENT.md +23 -0
  5. data/net-ssh-7.3.3/Dockerfile +29 -0
  6. data/net-ssh-7.3.3/Dockerfile.openssl3 +17 -0
  7. data/net-ssh-7.3.3/Dockerfile.zlib_ng +29 -0
  8. data/net-ssh-7.3.3/Gemfile +13 -0
  9. data/net-ssh-7.3.3/Gemfile.noed25519 +12 -0
  10. data/net-ssh-7.3.3/Gemfile.norbnacl +12 -0
  11. data/net-ssh-7.3.3/ISSUE_TEMPLATE.md +30 -0
  12. data/net-ssh-7.3.3/LICENSE.txt +19 -0
  13. data/net-ssh-7.3.3/Manifest +132 -0
  14. data/net-ssh-7.3.3/README.md +303 -0
  15. data/net-ssh-7.3.3/Rakefile +196 -0
  16. data/net-ssh-7.3.3/SECURITY.md +4 -0
  17. data/net-ssh-7.3.3/THANKS.txt +110 -0
  18. data/net-ssh-7.3.3/appveyor.yml +58 -0
  19. data/net-ssh-7.3.3/docker-compose.yml +23 -0
  20. data/net-ssh-7.3.3/lib/net/ssh/authentication/agent.rb +284 -0
  21. data/net-ssh-7.3.3/lib/net/ssh/authentication/certificate.rb +183 -0
  22. data/net-ssh-7.3.3/lib/net/ssh/authentication/constants.rb +20 -0
  23. data/net-ssh-7.3.3/lib/net/ssh/authentication/ed25519.rb +184 -0
  24. data/net-ssh-7.3.3/lib/net/ssh/authentication/ed25519_loader.rb +31 -0
  25. data/net-ssh-7.3.3/lib/net/ssh/authentication/key_manager.rb +342 -0
  26. data/net-ssh-7.3.3/lib/net/ssh/authentication/methods/abstract.rb +79 -0
  27. data/net-ssh-7.3.3/lib/net/ssh/authentication/methods/hostbased.rb +72 -0
  28. data/net-ssh-7.3.3/lib/net/ssh/authentication/methods/keyboard_interactive.rb +77 -0
  29. data/net-ssh-7.3.3/lib/net/ssh/authentication/methods/none.rb +34 -0
  30. data/net-ssh-7.3.3/lib/net/ssh/authentication/methods/password.rb +80 -0
  31. data/net-ssh-7.3.3/lib/net/ssh/authentication/methods/publickey.rb +137 -0
  32. data/net-ssh-7.3.3/lib/net/ssh/authentication/pageant.rb +497 -0
  33. data/net-ssh-7.3.3/lib/net/ssh/authentication/pub_key_fingerprint.rb +43 -0
  34. data/net-ssh-7.3.3/lib/net/ssh/authentication/session.rb +172 -0
  35. data/net-ssh-7.3.3/lib/net/ssh/buffer.rb +449 -0
  36. data/net-ssh-7.3.3/lib/net/ssh/buffered_io.rb +202 -0
  37. data/net-ssh-7.3.3/lib/net/ssh/config.rb +407 -0
  38. data/net-ssh-7.3.3/lib/net/ssh/connection/channel.rb +694 -0
  39. data/net-ssh-7.3.3/lib/net/ssh/connection/constants.rb +33 -0
  40. data/net-ssh-7.3.3/lib/net/ssh/connection/event_loop.rb +123 -0
  41. data/net-ssh-7.3.3/lib/net/ssh/connection/keepalive.rb +59 -0
  42. data/net-ssh-7.3.3/lib/net/ssh/connection/session.rb +712 -0
  43. data/net-ssh-7.3.3/lib/net/ssh/connection/term.rb +180 -0
  44. data/net-ssh-7.3.3/lib/net/ssh/errors.rb +106 -0
  45. data/net-ssh-7.3.3/lib/net/ssh/key_factory.rb +218 -0
  46. data/net-ssh-7.3.3/lib/net/ssh/known_hosts.rb +266 -0
  47. data/net-ssh-7.3.3/lib/net/ssh/loggable.rb +62 -0
  48. data/net-ssh-7.3.3/lib/net/ssh/packet.rb +106 -0
  49. data/net-ssh-7.3.3/lib/net/ssh/prompt.rb +62 -0
  50. data/net-ssh-7.3.3/lib/net/ssh/proxy/command.rb +123 -0
  51. data/net-ssh-7.3.3/lib/net/ssh/proxy/errors.rb +16 -0
  52. data/net-ssh-7.3.3/lib/net/ssh/proxy/http.rb +98 -0
  53. data/net-ssh-7.3.3/lib/net/ssh/proxy/https.rb +50 -0
  54. data/net-ssh-7.3.3/lib/net/ssh/proxy/jump.rb +54 -0
  55. data/net-ssh-7.3.3/lib/net/ssh/proxy/socks4.rb +67 -0
  56. data/net-ssh-7.3.3/lib/net/ssh/proxy/socks5.rb +140 -0
  57. data/net-ssh-7.3.3/lib/net/ssh/service/forward.rb +426 -0
  58. data/net-ssh-7.3.3/lib/net/ssh/test/channel.rb +147 -0
  59. data/net-ssh-7.3.3/lib/net/ssh/test/extensions.rb +174 -0
  60. data/net-ssh-7.3.3/lib/net/ssh/test/kex.rb +46 -0
  61. data/net-ssh-7.3.3/lib/net/ssh/test/local_packet.rb +53 -0
  62. data/net-ssh-7.3.3/lib/net/ssh/test/packet.rb +101 -0
  63. data/net-ssh-7.3.3/lib/net/ssh/test/remote_packet.rb +40 -0
  64. data/net-ssh-7.3.3/lib/net/ssh/test/script.rb +180 -0
  65. data/net-ssh-7.3.3/lib/net/ssh/test/socket.rb +65 -0
  66. data/net-ssh-7.3.3/lib/net/ssh/test.rb +94 -0
  67. data/net-ssh-7.3.3/lib/net/ssh/transport/aes128_gcm.rb +40 -0
  68. data/net-ssh-7.3.3/lib/net/ssh/transport/aes256_gcm.rb +40 -0
  69. data/net-ssh-7.3.3/lib/net/ssh/transport/algorithms.rb +531 -0
  70. data/net-ssh-7.3.3/lib/net/ssh/transport/chacha20_poly1305_cipher.rb +117 -0
  71. data/net-ssh-7.3.3/lib/net/ssh/transport/chacha20_poly1305_cipher_loader.rb +17 -0
  72. data/net-ssh-7.3.3/lib/net/ssh/transport/cipher_factory.rb +130 -0
  73. data/net-ssh-7.3.3/lib/net/ssh/transport/constants.rb +40 -0
  74. data/net-ssh-7.3.3/lib/net/ssh/transport/ctr.rb +115 -0
  75. data/net-ssh-7.3.3/lib/net/ssh/transport/gcm_cipher.rb +207 -0
  76. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/abstract.rb +113 -0
  77. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/md5.rb +10 -0
  78. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/md5_96.rb +9 -0
  79. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/none.rb +13 -0
  80. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/ripemd160.rb +11 -0
  81. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha1.rb +11 -0
  82. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha1_96.rb +9 -0
  83. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha2_256.rb +11 -0
  84. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha2_256_96.rb +9 -0
  85. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
  86. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha2_512.rb +11 -0
  87. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha2_512_96.rb +9 -0
  88. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
  89. data/net-ssh-7.3.3/lib/net/ssh/transport/hmac.rb +47 -0
  90. data/net-ssh-7.3.3/lib/net/ssh/transport/identity_cipher.rb +65 -0
  91. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/abstract.rb +130 -0
  92. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
  93. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
  94. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
  95. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +37 -0
  96. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
  97. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +122 -0
  98. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +72 -0
  99. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +11 -0
  100. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +39 -0
  101. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +21 -0
  102. data/net-ssh-7.3.3/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +21 -0
  103. data/net-ssh-7.3.3/lib/net/ssh/transport/kex.rb +31 -0
  104. data/net-ssh-7.3.3/lib/net/ssh/transport/key_expander.rb +30 -0
  105. data/net-ssh-7.3.3/lib/net/ssh/transport/openssl.rb +274 -0
  106. data/net-ssh-7.3.3/lib/net/ssh/transport/openssl_cipher_extensions.rb +8 -0
  107. data/net-ssh-7.3.3/lib/net/ssh/transport/packet_stream.rb +301 -0
  108. data/net-ssh-7.3.3/lib/net/ssh/transport/server_version.rb +77 -0
  109. data/net-ssh-7.3.3/lib/net/ssh/transport/session.rb +354 -0
  110. data/net-ssh-7.3.3/lib/net/ssh/transport/state.rb +208 -0
  111. data/net-ssh-7.3.3/lib/net/ssh/verifiers/accept_new.rb +33 -0
  112. data/net-ssh-7.3.3/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +33 -0
  113. data/net-ssh-7.3.3/lib/net/ssh/verifiers/always.rb +58 -0
  114. data/net-ssh-7.3.3/lib/net/ssh/verifiers/never.rb +19 -0
  115. data/net-ssh-7.3.3/lib/net/ssh/version.rb +68 -0
  116. data/net-ssh-7.3.3/lib/net/ssh.rb +334 -0
  117. data/net-ssh-7.3.3/net-ssh-public_cert.pem +21 -0
  118. data/net-ssh-7.3.3/net-ssh.gemspec +48 -0
  119. data/net-ssh-7.3.3/support/ssh_tunnel_bug.rb +65 -0
  120. metadata +158 -0
@@ -0,0 +1,19 @@
1
+ module Net
2
+ module SSH
3
+ module Verifiers
4
+ # This host key verifier simply allows every key it sees, without
5
+ # any verification. This is simple, but very insecure because it
6
+ # exposes you to MiTM attacks.
7
+ class Never
8
+ # Returns true.
9
+ def verify(arguments)
10
+ true
11
+ end
12
+
13
+ def verify_signature(&block)
14
+ true
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,68 @@
1
+ module Net
2
+ module SSH
3
+ # A class for describing the current version of a library. The version
4
+ # consists of three parts: the +major+ number, the +minor+ number, and the
5
+ # +tiny+ (or +patch+) number.
6
+ #
7
+ # Two Version instances may be compared, so that you can test that a version
8
+ # of a library is what you require:
9
+ #
10
+ # require 'net/ssh/version'
11
+ #
12
+ # if Net::SSH::Version::CURRENT < Net::SSH::Version[2,1,0]
13
+ # abort "your software is too old!"
14
+ # end
15
+ class Version
16
+ include Comparable
17
+
18
+ # A convenience method for instantiating a new Version instance with the
19
+ # given +major+, +minor+, and +tiny+ components.
20
+ def self.[](major, minor, tiny, pre = nil)
21
+ new(major, minor, tiny, pre)
22
+ end
23
+
24
+ attr_reader :major, :minor, :tiny
25
+
26
+ # Create a new Version object with the given components.
27
+ def initialize(major, minor, tiny, pre = nil)
28
+ @major, @minor, @tiny, @pre = major, minor, tiny, pre
29
+ end
30
+
31
+ # Compare this version to the given +version+ object.
32
+ def <=>(version)
33
+ to_i <=> version.to_i
34
+ end
35
+
36
+ # Converts this version object to a string, where each of the three
37
+ # version components are joined by the '.' character. E.g., 2.0.0.
38
+ def to_s
39
+ @to_s ||= [@major, @minor, @tiny, @pre].compact.join(".")
40
+ end
41
+
42
+ # Converts this version to a canonical integer that may be compared
43
+ # against other version objects.
44
+ def to_i
45
+ @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
46
+ end
47
+
48
+ # The major component of this version of the Net::SSH library
49
+ MAJOR = 7
50
+
51
+ # The minor component of this version of the Net::SSH library
52
+ MINOR = 3
53
+
54
+ # The tiny component of this version of the Net::SSH library
55
+ TINY = 3
56
+
57
+ # The prerelease component of this version of the Net::SSH library
58
+ # nil allowed
59
+ PRE = nil
60
+
61
+ # The current version of the Net::SSH library as a Version instance
62
+ CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)
63
+
64
+ # The current version of the Net::SSH library as a String
65
+ STRING = CURRENT.to_s
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,334 @@
1
+ require 'logger'
2
+ require 'etc'
3
+ require 'shellwords'
4
+
5
+ require 'net/ssh/config'
6
+ require 'net/ssh/errors'
7
+ require 'net/ssh/loggable'
8
+ require 'net/ssh/transport/session'
9
+ require 'net/ssh/authentication/session'
10
+ require 'net/ssh/connection/session'
11
+ require 'net/ssh/prompt'
12
+
13
+ module Net
14
+ # Net::SSH is a library for interacting, programmatically, with remote
15
+ # processes via the SSH2 protocol. Sessions are always initiated via
16
+ # Net::SSH.start. From there, a program interacts with the new SSH session
17
+ # via the convenience methods on Net::SSH::Connection::Session, by opening
18
+ # and interacting with new channels (Net::SSH::Connection:Session#open_channel
19
+ # and Net::SSH::Connection::Channel), or by forwarding local and/or
20
+ # remote ports through the connection (Net::SSH::Service::Forward).
21
+ #
22
+ # The SSH protocol is very event-oriented. Requests are sent from the client
23
+ # to the server, and are answered asynchronously. This gives great flexibility
24
+ # (since clients can have multiple requests pending at a time), but it also
25
+ # adds complexity. Net::SSH tries to manage this complexity by providing
26
+ # some simpler methods of synchronous communication (see Net::SSH::Connection::Session#exec!).
27
+ #
28
+ # In general, though, and if you want to do anything more complicated than
29
+ # simply executing commands and capturing their output, you'll need to use
30
+ # channels (Net::SSH::Connection::Channel) to build state machines that are
31
+ # executed while the event loop runs (Net::SSH::Connection::Session#loop).
32
+ #
33
+ # Net::SSH::Connection::Session and Net::SSH::Connection::Channel have more
34
+ # information about this technique.
35
+ #
36
+ # = "Um, all I want to do is X, just show me how!"
37
+ #
38
+ # == X == "execute a command and capture the output"
39
+ #
40
+ # Net::SSH.start("host", "user", password: "password") do |ssh|
41
+ # result = ssh.exec!("ls -l")
42
+ # puts result
43
+ # end
44
+ #
45
+ # == X == "forward connections on a local port to a remote host"
46
+ #
47
+ # Net::SSH.start("host", "user", password: "password") do |ssh|
48
+ # ssh.forward.local(1234, "www.google.com", 80)
49
+ # ssh.loop { true }
50
+ # end
51
+ #
52
+ # == X == "forward connections on a remote port to the local host"
53
+ #
54
+ # Net::SSH.start("host", "user", password: "password") do |ssh|
55
+ # ssh.forward.remote(80, "www.google.com", 1234)
56
+ # ssh.loop { true }
57
+ # end
58
+ module SSH
59
+ # This is the set of options that Net::SSH.start recognizes. See
60
+ # Net::SSH.start for a description of each option.
61
+ VALID_OPTIONS = %i[
62
+ auth_methods bind_address compression compression_level config
63
+ encryption forward_agent hmac host_key identity_agent remote_user
64
+ keepalive keepalive_interval keepalive_maxcount kex keys key_data
65
+ keycerts keycert_data languages logger paranoid password port proxy
66
+ rekey_blocks_limit rekey_limit rekey_packet_limit timeout verbose
67
+ known_hosts global_known_hosts_file user_known_hosts_file host_key_alias
68
+ host_name user properties passphrase keys_only max_pkt_size
69
+ max_win_size send_env set_env use_agent number_of_password_prompts
70
+ append_all_supported_algorithms non_interactive password_prompt
71
+ agent_socket_factory minimum_dh_bits verify_host_key
72
+ fingerprint_hash check_host_ip pubkey_algorithms
73
+ ]
74
+
75
+ # The standard means of starting a new SSH connection. When used with a
76
+ # block, the connection will be closed when the block terminates, otherwise
77
+ # the connection will just be returned. The yielded (or returned) value
78
+ # will be an instance of Net::SSH::Connection::Session (q.v.). (See also
79
+ # Net::SSH::Connection::Channel and Net::SSH::Service::Forward.)
80
+ #
81
+ # Net::SSH.start("host", "user") do |ssh|
82
+ # ssh.exec! "cp /some/file /another/location"
83
+ # hostname = ssh.exec!("hostname")
84
+ #
85
+ # ssh.open_channel do |ch|
86
+ # ch.exec "sudo -p 'sudo password: ' ls" do |ch, success|
87
+ # abort "could not execute sudo ls" unless success
88
+ #
89
+ # ch.on_data do |ch, data|
90
+ # print data
91
+ # if data =~ /sudo password: /
92
+ # ch.send_data("password\n")
93
+ # end
94
+ # end
95
+ # end
96
+ # end
97
+ #
98
+ # ssh.loop
99
+ # end
100
+ #
101
+ # This method accepts the following options (all are optional):
102
+ #
103
+ # * :auth_methods => an array of authentication methods to try
104
+ # * :bind_address => the IP address on the connecting machine to use in
105
+ # establishing connection. (:bind_address is discarded if :proxy
106
+ # is set.)
107
+ # * :check_host_ip => Also check IP address when connecting to remote host.
108
+ # Defaults to +true+.
109
+ # * :compression => the compression algorithm to use, or +true+ to use
110
+ # whatever is supported.
111
+ # * :compression_level => the compression level to use when sending data
112
+ # * :config => set to +true+ to load the default OpenSSH config files
113
+ # (~/.ssh/config, /etc/ssh_config), or to +false+ to not load them, or to
114
+ # a file-name (or array of file-names) to load those specific configuration
115
+ # files. Defaults to +true+.
116
+ # * :encryption => the encryption cipher (or ciphers) to use
117
+ # * :forward_agent => set to true if you want the SSH agent connection to
118
+ # be forwarded
119
+ # * :known_hosts => a custom object holding known hosts records.
120
+ # It must implement #search_for and `add` in a similiar manner as KnownHosts.
121
+ # * :global_known_hosts_file => the location of the global known hosts
122
+ # file. Set to an array if you want to specify multiple global known
123
+ # hosts files. Defaults to %w(/etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2).
124
+ # * :hmac => the hmac algorithm (or algorithms) to use
125
+ # * :host_key => the host key algorithm (or algorithms) to use
126
+ # * :host_key_alias => the host name to use when looking up or adding a
127
+ # host to a known_hosts dictionary file
128
+ # * :host_name => the real host name or IP to log into. This is used
129
+ # instead of the +host+ parameter, and is primarily only useful when
130
+ # specified in an SSH configuration file. It lets you specify an
131
+ # "alias", similarly to adding an entry in /etc/hosts but without needing
132
+ # to modify /etc/hosts.
133
+ # * :keepalive => set to +true+ to send a keepalive packet to the SSH server
134
+ # when there's no traffic between the SSH server and Net::SSH client for
135
+ # the keepalive_interval seconds. Defaults to +false+.
136
+ # * :keepalive_interval => the interval seconds for keepalive.
137
+ # Defaults to +300+ seconds.
138
+ # * :keepalive_maxcount => the maximun number of keepalive packet miss allowed.
139
+ # Defaults to 3
140
+ # * :kex => the key exchange algorithm (or algorithms) to use
141
+ # * :keys => an array of file names of private keys to use for publickey
142
+ # and hostbased authentication
143
+ # * :keycerts => an array of file names of key certificates to use
144
+ # with publickey authentication
145
+ # * :keycert_data => an array of strings, which each element of the array
146
+ # being a key certificate to use with publickey authentication
147
+ # * :key_data => an array of strings, with each element of the array being
148
+ # a raw private key in PEM format.
149
+ # * :keys_only => set to +true+ to use only private keys from +keys+ and
150
+ # +key_data+ parameters, even if ssh-agent offers more identities. This
151
+ # option is intended for situations where ssh-agent offers many different
152
+ # identites.
153
+ # * :logger => the logger instance to use when logging
154
+ # * :max_pkt_size => maximum size we tell the other side that is supported per
155
+ # packet. Default is 0x8000 (32768 bytes). Increase to 0x10000 (65536 bytes)
156
+ # for better performance if your SSH server supports it (most do).
157
+ # * :max_win_size => maximum size we tell the other side that is supported for
158
+ # the window.
159
+ # * :non_interactive => set to true if your app is non interactive and prefers
160
+ # authentication failure vs password prompt. Non-interactive applications
161
+ # should set it to true to prefer failing a password/etc auth methods vs.
162
+ # asking for password.
163
+ # * :paranoid => deprecated alias for :verify_host_key
164
+ # * :passphrase => the passphrase to use when loading a private key (default
165
+ # is +nil+, for no passphrase)
166
+ # * :password => the password to use to login
167
+ # * :port => the port to use when connecting to the remote host
168
+ # * :properties => a hash of key/value pairs to add to the new connection's
169
+ # properties (see Net::SSH::Connection::Session#properties)
170
+ # * :proxy => a proxy instance (see Proxy) to use when connecting
171
+ # * :pubkey_algorithms => the public key authentication algorithms to use for
172
+ # this connection. Valid values are 'rsa-sha2-256-cert-v01@openssh.com',
173
+ # 'ssh-rsa-cert-v01@openssh.com', 'rsa-sha2-256', 'ssh-rsa'. Currently, this
174
+ # option is only used for RSA public key authentication and ignored for other
175
+ # types.
176
+ # * :rekey_blocks_limit => the max number of blocks to process before rekeying
177
+ # * :rekey_limit => the max number of bytes to process before rekeying
178
+ # * :rekey_packet_limit => the max number of packets to process before rekeying
179
+ # * :send_env => an array of local environment variable names to export to the
180
+ # remote environment. Names may be given as String or Regexp.
181
+ # * :set_env => a hash of environment variable names and values to set to the
182
+ # remote environment. Override the ones if specified in +send_env+.
183
+ # * :timeout => how long to wait for the initial connection to be made
184
+ # * :user => the user name to log in as; this overrides the +user+
185
+ # parameter, and is primarily only useful when provided via an SSH
186
+ # configuration file.
187
+ # * :remote_user => used for substitution into the '%r' part of a ProxyCommand
188
+ # * :user_known_hosts_file => the location of the user known hosts file.
189
+ # Set to an array to specify multiple user known hosts files.
190
+ # Defaults to %w(~/.ssh/known_hosts ~/.ssh/known_hosts2).
191
+ # * :use_agent => Set false to disable the use of ssh-agent. Defaults to
192
+ # true
193
+ # * :identity_agent => the path to the ssh-agent's UNIX socket
194
+ # * :verbose => how verbose to be (Logger verbosity constants, Logger::DEBUG
195
+ # is very verbose, Logger::FATAL is all but silent). Logger::FATAL is the
196
+ # default. The symbols :debug, :info, :warn, :error, and :fatal are also
197
+ # supported and are translated to the corresponding Logger constant.
198
+ # * :append_all_supported_algorithms => set to +true+ to append all supported
199
+ # algorithms by net-ssh. Was the default behaviour until 2.10
200
+ # * :number_of_password_prompts => Number of prompts for the password
201
+ # authentication method defaults to 3 set to 0 to disable prompt for
202
+ # password auth method
203
+ # * :password_prompt => a custom prompt object with ask method. See Net::SSH::Prompt
204
+ #
205
+ # * :agent_socket_factory => enables the user to pass a lambda/block that will serve as the socket factory
206
+ # Net::SSH.start(host,user,agent_socket_factory: ->{ UNIXSocket.open('/foo/bar') })
207
+ # example: ->{ UNIXSocket.open('/foo/bar')}
208
+ # * :verify_host_key => specify how strict host-key verification should be.
209
+ # In order of increasing strictness:
210
+ # * :never (very insecure) ::Net::SSH::Verifiers::Never
211
+ # * :accept_new_or_local_tunnel (insecure) ::Net::SSH::Verifiers::AcceptNewOrLocalTunnel
212
+ # * :accept_new (insecure) ::Net::SSH::Verifiers::AcceptNew
213
+ # * :always (secure) ::Net::SSH::Verifiers::Always
214
+ # You can also provide an own Object which responds to +verify+. The argument
215
+ # given to +verify+ is a hash consisting of the +:key+, the +:key_blob+,
216
+ # the +:fingerprint+ and the +:session+. Returning true accepts the host key,
217
+ # returning false declines it and closes the connection.
218
+ # * :fingerprint_hash => 'MD5' or 'SHA256', defaults to 'SHA256'
219
+ # If +user+ parameter is nil it defaults to USER from ssh_config, or
220
+ # local username
221
+ def self.start(host, user = nil, options = {}, &block)
222
+ invalid_options = options.keys - VALID_OPTIONS
223
+ if invalid_options.any?
224
+ raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}"
225
+ end
226
+
227
+ assign_defaults(options)
228
+ _sanitize_options(options)
229
+
230
+ options[:user] = user if user
231
+ options = configuration_for(host, options.fetch(:config, true)).merge(options)
232
+ host = options.fetch(:host_name, host)
233
+
234
+ options[:check_host_ip] = true unless options.key?(:check_host_ip)
235
+
236
+ if options[:non_interactive]
237
+ options[:number_of_password_prompts] = 0
238
+ end
239
+
240
+ _support_deprecated_option_paranoid(options)
241
+
242
+ if options[:verbose]
243
+ options[:logger].level = case options[:verbose]
244
+ when Integer then options[:verbose]
245
+ when :debug then Logger::DEBUG
246
+ when :info then Logger::INFO
247
+ when :warn then Logger::WARN
248
+ when :error then Logger::ERROR
249
+ when :fatal then Logger::FATAL
250
+ else raise ArgumentError, "can't convert #{options[:verbose].inspect} to any of the Logger level constants"
251
+ end
252
+ end
253
+
254
+ transport = Transport::Session.new(host, options)
255
+ auth = Authentication::Session.new(transport, options)
256
+
257
+ user = options.fetch(:user, user) || Etc.getpwuid.name
258
+ if auth.authenticate("ssh-connection", user, options[:password])
259
+ connection = Connection::Session.new(transport, options)
260
+ if block_given?
261
+ begin
262
+ yield connection
263
+ ensure
264
+ connection.close unless connection.closed?
265
+ end
266
+ else
267
+ return connection
268
+ end
269
+ else
270
+ transport.close
271
+ raise AuthenticationFailed, "Authentication failed for user #{user}@#{host}"
272
+ end
273
+ end
274
+
275
+ # Returns a hash of the configuration options for the given host, as read
276
+ # from the SSH configuration file(s). If +use_ssh_config+ is true (the
277
+ # default), this will load configuration from both ~/.ssh/config and
278
+ # /etc/ssh_config. If +use_ssh_config+ is nil or false, nothing will be
279
+ # loaded (and an empty hash returned). Otherwise, +use_ssh_config+ may
280
+ # be a file name (or array of file names) of SSH configuration file(s)
281
+ # to read.
282
+ #
283
+ # See Net::SSH::Config for the full description of all supported options.
284
+ def self.configuration_for(host, use_ssh_config)
285
+ files = case use_ssh_config
286
+ when true then Net::SSH::Config.expandable_default_files
287
+ when false, nil then return {}
288
+ else Array(use_ssh_config)
289
+ end
290
+
291
+ Net::SSH::Config.for(host, files)
292
+ end
293
+
294
+ def self.assign_defaults(options)
295
+ if !options[:logger]
296
+ options[:logger] = Logger.new(STDERR)
297
+ options[:logger].level = Logger::FATAL
298
+ end
299
+
300
+ options[:password_prompt] ||= Prompt.default(options)
301
+
302
+ %i[password passphrase].each do |key|
303
+ options.delete(key) if options.key?(key) && options[key].nil?
304
+ end
305
+ end
306
+
307
+ def self._sanitize_options(options)
308
+ invalid_option_values = [nil, [nil]]
309
+ unless (options.values & invalid_option_values).empty?
310
+ nil_options = options.select { |_k, v| invalid_option_values.include?(v) }.map(&:first)
311
+ Kernel.warn "#{caller_locations(2, 1)[0]}: Passing nil, or [nil] to Net::SSH.start is deprecated for keys: #{nil_options.join(', ')}"
312
+ end
313
+ end
314
+ private_class_method :_sanitize_options
315
+
316
+ def self._support_deprecated_option_paranoid(options)
317
+ if options.key?(:paranoid)
318
+ Kernel.warn(
319
+ ":paranoid is deprecated, please use :verify_host_key. Supported " \
320
+ "values are exactly the same, only the name of the option has changed."
321
+ )
322
+ if options.key?(:verify_host_key)
323
+ Kernel.warn(
324
+ "Both :paranoid and :verify_host_key were specified. " \
325
+ ":verify_host_key takes precedence, :paranoid will be ignored."
326
+ )
327
+ else
328
+ options[:verify_host_key] = options.delete(:paranoid)
329
+ end
330
+ end
331
+ end
332
+ private_class_method :_support_deprecated_option_paranoid
333
+ end
334
+ end
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZuZXRz
3
+ c2gxGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZFgNj
4
+ b20wHhcNMjYwMjE1MTAxNzUyWhcNMjcwMjE1MTAxNzUyWjBBMQ8wDQYDVQQDDAZu
5
+ ZXRzc2gxGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZ
6
+ FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGJ4TbZ9H+qZ08
7
+ pQfJhPJTHaDCyQvCsKTFrL5O9z3tllQ7B/zksMMM+qFBpNYu9HCcg4yBATacE/PB
8
+ qVVyUrpr6lbH/XwoN5ljXm+bdCfmnjZvTCL2FTE6o+bcnaF0IsJyC0Q2B1fbWdXN
9
+ 6Off1ZWoUk6We2BIM1bn6QJLxBpGyYhvOPXsYoqSuzDf2SJDDsWFZ8kV5ON13Ohm
10
+ JbBzn0oD8HF8FuYOewwsC0C1q4w7E5GtvHcQ5juweS7+RKsyDcVcVrLuNzoGRttS
11
+ KP4yMn+TzaXijyjRg7gECfJr3TGASaA4bQsILFGG5dAWcwO4OMrZedR7SHj/o0Kf
12
+ 3gL7P0axAgMBAAGjezB5MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
13
+ BBQF8qLA7Z4zg0SJGtUbv3eoQ8tjIzAfBgNVHREEGDAWgRRuZXRzc2hAc29sdXRp
14
+ b3VzLmNvbTAfBgNVHRIEGDAWgRRuZXRzc2hAc29sdXRpb3VzLmNvbTANBgkqhkiG
15
+ 9w0BAQsFAAOCAQEASsiVybehJLRPztFeFV8+SKa2BwbBSNJoAkhARVJKhpJxCfeY
16
+ gO7Kqb7JCykzb0anb1s6xTrzD03cWRNGE2YaoBLqnzeUqW1LPqVwmcySmnSIGH9F
17
+ DlFYlHaAn3oSqglyDxQx9bLngKatetx+tSfB3bLAb7Tr9PO8/lhBENbjlD4+UUwD
18
+ gApoZuD9pknWDH3KsITgzphswETBdo0hd9aLnRNR3EifD0lUIEit/0Yx6euSxWtI
19
+ ufHf4AX2UIkJbh7zCPkiNCqIr7MSWLNFG/9lOlHYsEJM8XujT1ofPobYx6YSFx/C
20
+ 7HBrI7UX7awt6UvBZebhcHzyMHxg/B5PVQllPA==
21
+ -----END CERTIFICATE-----
@@ -0,0 +1,48 @@
1
+ require_relative 'lib/net/ssh/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "net-ssh"
5
+ spec.version = Net::SSH::Version::STRING
6
+ spec.authors = ["Jamis Buck", "Delano Mandelbaum", "Mikl\u{f3}s Fazekas"]
7
+ spec.email = ["net-ssh@solutious.com"]
8
+
9
+ if ENV['NET_SSH_BUILDGEM_SIGNED']
10
+ spec.cert_chain = ["net-ssh-public_cert.pem"]
11
+ spec.signing_key = "/mnt/gem/net-ssh-private_key.pem"
12
+ end
13
+
14
+ spec.summary = %q{Net::SSH: a pure-Ruby implementation of the SSH2 client protocol.}
15
+ spec.description = %q{Net::SSH: 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.}
16
+ spec.homepage = "https://github.com/net-ssh/net-ssh"
17
+ spec.license = "MIT"
18
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
19
+ spec.metadata = {
20
+ "changelog_uri" => "https://github.com/net-ssh/net-ssh/blob/master/CHANGES.txt"
21
+ }
22
+
23
+ spec.extra_rdoc_files = [
24
+ "LICENSE.txt",
25
+ "README.md"
26
+ ]
27
+
28
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ unless ENV['NET_SSH_NO_ED25519']
34
+ spec.add_development_dependency("bcrypt_pbkdf", "~> 1.0") unless RUBY_PLATFORM == "java"
35
+ spec.add_development_dependency("ed25519", "~> 1.2")
36
+ spec.add_development_dependency('x25519') unless RUBY_PLATFORM == 'java'
37
+ end
38
+
39
+ spec.add_development_dependency('rbnacl', '~> 7.1') unless ENV['NET_SSH_NO_RBNACL']
40
+
41
+ spec.add_development_dependency "base64"
42
+ spec.add_development_dependency "bundler", ">= 1.17"
43
+ spec.add_development_dependency "minitest", "~> 5.19"
44
+ spec.add_development_dependency "mocha", "~> 2.1.0"
45
+ spec.add_development_dependency "ostruct"
46
+ spec.add_development_dependency "rake", "~> 12.0"
47
+ spec.add_development_dependency "rubocop", "~> 1.28.0"
48
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # SSH TUNNEL CONNECTION BUG
4
+ # from: http://net-ssh.lighthouseapp.com/projects/36253/tickets/7-an-existing-connection-was-forcibly-closed-by-the-remote-host#ticket-7-3
5
+ #
6
+ # Steps to reproduce:
7
+ #
8
+ # * Start HTTP Proxy
9
+ # * If running debian in EC2:
10
+ # * apt-get install squid
11
+ # * Add the following to /etc/squid/squid.conf:
12
+ # acl localnet src 1.2.3.0/255.255.255.0
13
+ # http_access allow localnet
14
+ # icp_access allow localnet
15
+ # visible_hostname netsshtest
16
+ # * Start squid squid -N -d 1 -D
17
+ # * Run this script
18
+ # * Configure browser proxy to use localhost with LOCAL_PORT.
19
+ # * Load any page, wait for it to load fully. If the page loads
20
+ # correctly, move on. If not, something needs to be corrected.
21
+ # * Refresh the page several times. This should cause this
22
+ # script to failed with the error: "closed stream". You may
23
+ # need to try a few times.
24
+ #
25
+
26
+ require 'highline/import'
27
+ require 'net/ssh'
28
+
29
+ LOCAL_PORT = 8080
30
+ PROXY_PORT = 3128
31
+
32
+ host, user = *ARGV
33
+ abort "Usage: #{$0} host user" unless ARGV.size == 2
34
+
35
+ puts "Connecting to #{user}@#{host}..."
36
+ pass = ask("Password: ") { |q| q.echo = "*" }
37
+ puts "Configure your browser proxy to localhost:#{LOCAL_PORT}"
38
+
39
+ begin
40
+ session = Net::SSH.start(host, user, password: pass)
41
+ session.forward.local(LOCAL_PORT, host, PROXY_PORT)
42
+ session.loop {true}
43
+ rescue StandardError => e
44
+ puts e.message
45
+ puts e.backtrace
46
+ end
47
+
48
+
49
+ __END__
50
+
51
+ $ ruby support/ssh_tunnel.rb host user
52
+ Connecting to user@host...
53
+ Password: ******
54
+ Configure your browser proxy to localhost:8080
55
+ closed stream
56
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/buffered_io.rb:99:in `send'
57
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/buffered_io.rb:99:in `send_pending'
58
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:236:in `block in postprocess'
59
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:235:in `each'
60
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:235:in `postprocess'
61
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:203:in `process'
62
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:161:in `block in loop'
63
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:161:in `loop'
64
+ /usr/local/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb:161:in `loop'
65
+