vagrant-unbundled 2.2.14.0 → 2.2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -0
- data/bin/vagrant +27 -1
- data/contrib/README.md +1 -1
- data/lib/vagrant.rb +3 -1
- data/lib/vagrant/action/builtin/box_add.rb +13 -3
- data/lib/vagrant/action/builtin/box_check_outdated.rb +2 -1
- data/lib/vagrant/bundler.rb +15 -5
- data/lib/vagrant/environment.rb +1 -0
- data/lib/vagrant/errors.rb +12 -0
- data/lib/vagrant/machine_index.rb +1 -1
- data/lib/vagrant/patches/net-ssh.rb +186 -0
- data/lib/vagrant/plugin/manager.rb +20 -2
- data/lib/vagrant/util.rb +1 -0
- data/lib/vagrant/util/curl_helper.rb +7 -6
- data/lib/vagrant/util/guest_hosts.rb +1 -1
- data/lib/vagrant/util/numeric.rb +20 -0
- data/lib/vagrant/util/powershell.rb +30 -14
- data/lib/vagrant/vagrantfile.rb +1 -1
- data/plugins/commands/cloud/auth/middleware/add_authentication.rb +60 -31
- data/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb +34 -27
- data/plugins/commands/cloud/client/client.rb +10 -3
- data/plugins/commands/cloud/locales/en.yml +5 -1
- data/plugins/commands/cloud/provider/upload.rb +10 -0
- data/plugins/commands/cloud/publish.rb +10 -0
- data/plugins/commands/cloud/util.rb +10 -2
- data/plugins/commands/destroy/command.rb +1 -5
- data/plugins/guests/alpine/cap/configure_networks.rb +1 -1
- data/plugins/guests/fedora/guest.rb +4 -4
- data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +1 -1
- data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +1 -2
- data/plugins/guests/linux/cap/reboot.rb +21 -3
- data/plugins/guests/openwrt/cap/change_host_name.rb +19 -0
- data/plugins/guests/openwrt/cap/halt.rb +16 -0
- data/plugins/guests/openwrt/cap/insert_public_key.rb +20 -0
- data/plugins/guests/openwrt/cap/remove_public_key.rb +22 -0
- data/plugins/guests/openwrt/cap/rsync.rb +35 -0
- data/plugins/guests/openwrt/guest.rb +23 -0
- data/plugins/guests/openwrt/plugin.rb +61 -0
- data/plugins/providers/docker/driver.rb +2 -2
- data/plugins/providers/virtualbox/action/network.rb +12 -5
- data/plugins/providers/virtualbox/cap/mount_options.rb +5 -0
- data/plugins/providers/virtualbox/plugin.rb +5 -0
- data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +1 -1
- data/plugins/provisioners/salt/bootstrap-salt.sh +7 -4
- data/plugins/synced_folders/smb/cap/mount_options.rb +2 -2
- data/templates/commands/init/Vagrantfile.min.erb +3 -0
- data/templates/guests/nixos/network.erb +5 -6
- data/templates/locales/en.yml +21 -4
- data/vagrant.gemspec +5 -11
- data/version.txt +1 -1
- metadata +2921 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84c5c51fc0678552529c308c36ba4c93114e71aee93c062b7993ad7bc4bab6d8
|
4
|
+
data.tar.gz: 7ad1f71440d48b09436fde379347a1008fc32ad7e9378187750bb3421b94e202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c643c0795943406343de52a7db6e85e9114336133cdc89105abcaee498c9547efc9530788bfc797df2b893240dbdeff3f57c6a65622cf335b255e1bbe09d2b26
|
7
|
+
data.tar.gz: 2ef84ae4bd47a7e4a0026be3f60d86369c95103659bfdc32ecee8f340191643b8518e0a948e5d446b982af6bfa3230ecbd388166ba4334c3d8e310f56cb003d3
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,56 @@
|
|
1
|
+
## 2.2.16 (April 29, 2021)
|
2
|
+
|
3
|
+
IMPROVEMENTS:
|
4
|
+
|
5
|
+
- guest/linux: Detect in process shutdown in reboot capability [GH-12302]
|
6
|
+
- util/powershell: Support `pwsh` executable in new versions of powershell [GH-12335]
|
7
|
+
|
8
|
+
BUG FIXES:
|
9
|
+
|
10
|
+
- core: Add box directly with authed urls [GH-12278]
|
11
|
+
- communicator/ssh: Properly handle authentication with RSA keys [GH-12298]
|
12
|
+
- guest/fedora: Import guest detection module [GH-12275]
|
13
|
+
- guest/linux: Fix SMB folder mount name capability call [GH-12281]
|
14
|
+
- provider/docker: Properly handle updated buildkit build output [GH-12300]
|
15
|
+
|
16
|
+
## 2.2.15 (March 30, 2021)
|
17
|
+
|
18
|
+
IMPROVEMENTS:
|
19
|
+
|
20
|
+
- command/cloud: Remove access token URL parameter by default [GH-12234]
|
21
|
+
- command/cloud: Add VAGRANT_SERVER_ACCESS_TOKEN_BY_URL to revert access token behavior [GH-12252]
|
22
|
+
- core: Bump vagrant_cloud dependency to 3.0.3 [GH-12200]
|
23
|
+
- core: Bump listen gem version and remove ruby_dep [GH-12148]
|
24
|
+
- core: Bump vagrant_cloud dependency to 3.0.4 [GH-12242]
|
25
|
+
- core/bundler: Update resolution handling when outside of installer and bundler [GH-12225]
|
26
|
+
- core/plugin: Provide friendlier error messages on install fail when possible [GH-12225]
|
27
|
+
- guest/openwrt: Add support for OpenWrt guests [GH-11791]
|
28
|
+
- guest/freebsd: FreeBSD updated ansible to py37-ansible [GH-12201]
|
29
|
+
- provider/virtualbox: Get default dhcp ip from a matching host ip [GH-12211]
|
30
|
+
- util/downloader: Prevent redirect notification for default store [GH-12235]
|
31
|
+
|
32
|
+
BUG FIXES:
|
33
|
+
|
34
|
+
- command/cloud: Automatically disable direct uploads when file is too large [GH-12250]
|
35
|
+
- core: Make shell script for loop shell agnostic [GH-12205]
|
36
|
+
- core: Raise error if downloading box metadata fails [GH-12189]
|
37
|
+
- core: Apply download options to metadata requests [GH-12177]
|
38
|
+
- core: Don't try to find "" by prefix in the machine index [GH-12188]
|
39
|
+
- core: Don't count not created machines as declined when destroying [GH-12186]
|
40
|
+
- core: Bump bcrypt_pbkdf version [GH-12216]
|
41
|
+
- core: Remove all space from checksums [GH-12168]
|
42
|
+
- core/bundler: Do not include default gems as pinned constraints [GH-12253]
|
43
|
+
- core/synced_folders: Extract os friendly mount name for vbox shared folders [GH-12184]
|
44
|
+
- guest/alpine: Check if interface exists before shutting it down [GH-12181]
|
45
|
+
- guest/nixos: Fix network config for recent NixOS releases [GH-12152]
|
46
|
+
- guest/fedora: Detect fedora using os-releases id [GH-12230]
|
47
|
+
|
1
48
|
## 2.2.14 (November 20, 2020)
|
2
49
|
|
3
50
|
IMPROVEMENTS:
|
4
51
|
|
5
52
|
- host/windows: Update filesystem type matching on WSL2 [GH-12056]
|
53
|
+
- provisioner/salt: Modernize Salt bootstrap script [GH-12135]
|
6
54
|
|
7
55
|
BUG FIXES:
|
8
56
|
|
@@ -3363,6 +3411,10 @@ BACKWARDS INCOMPATIBILITIES:
|
|
3363
3411
|
format, but this is _opt-in_. Old Vagrantfile format continues to be supported,
|
3364
3412
|
as promised. To use the new features that will be introduced throughout
|
3365
3413
|
the 1.x series, you'll have to upgrade at some point.
|
3414
|
+
- The .vagrant file is no longer supported and has been replaced by
|
3415
|
+
a .vagrant directory. Running vagrant will automatically upgrade
|
3416
|
+
to the new style directory format, after which old versions of
|
3417
|
+
Vagrant will not be able to see or control your VM.
|
3366
3418
|
|
3367
3419
|
FEATURES:
|
3368
3420
|
|
data/bin/vagrant
CHANGED
@@ -23,9 +23,9 @@ if idx = argv.index("--")
|
|
23
23
|
argv = argv.slice(0, idx)
|
24
24
|
end
|
25
25
|
|
26
|
+
require_relative "../lib/vagrant/version"
|
26
27
|
# Fast path the version of Vagrant
|
27
28
|
if argv.include?("-v") || argv.include?("--version")
|
28
|
-
require_relative "../lib/vagrant/version"
|
29
29
|
puts "Vagrant #{Vagrant::VERSION}"
|
30
30
|
exit 0
|
31
31
|
end
|
@@ -82,6 +82,29 @@ end
|
|
82
82
|
$stdout.sync = true
|
83
83
|
$stderr.sync = true
|
84
84
|
|
85
|
+
# Before we start activate all our dependencies
|
86
|
+
# so we can provide correct resolutions later
|
87
|
+
builtin_specs = []
|
88
|
+
|
89
|
+
vagrant_spec = Gem::Specification.find_all_by_name("vagrant").detect do |spec|
|
90
|
+
spec.version == Gem::Version.new(Vagrant::VERSION)
|
91
|
+
end
|
92
|
+
|
93
|
+
dep_activator = proc do |spec|
|
94
|
+
spec.runtime_dependencies.each do |dep|
|
95
|
+
gem(dep.name, *dep.requirement.as_list)
|
96
|
+
dep_spec = Gem::Specification.find_all_by_name(dep.name).detect(&:activated?)
|
97
|
+
if dep_spec
|
98
|
+
builtin_specs << dep_spec
|
99
|
+
dep_activator.call(dep_spec)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
if vagrant_spec
|
105
|
+
dep_activator.call(vagrant_spec)
|
106
|
+
end
|
107
|
+
|
85
108
|
env = nil
|
86
109
|
begin
|
87
110
|
require 'log4r'
|
@@ -91,6 +114,9 @@ begin
|
|
91
114
|
require 'vagrant/util/platform'
|
92
115
|
require 'vagrant/util/experimental'
|
93
116
|
|
117
|
+
# Set our list of builtin specs
|
118
|
+
Vagrant::Bundler.instance.builtin_specs = builtin_specs
|
119
|
+
|
94
120
|
# Schedule the cleanup of things
|
95
121
|
at_exit(&Vagrant::Bundler.instance.method(:deinit))
|
96
122
|
|
data/contrib/README.md
CHANGED
@@ -14,4 +14,4 @@ for each item will be kept below.
|
|
14
14
|
starting machines.
|
15
15
|
* `vim` - Contains a `.vim` file for enabling Ruby syntax highlighting
|
16
16
|
for `Vagrantfile`s in `vim`.
|
17
|
-
|
17
|
+
* `zsh` - Contains a zsh script for improving autocompletion with zsh.
|
data/lib/vagrant.rb
CHANGED
@@ -9,6 +9,8 @@ class Log4r::BasicFormatter
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
# Add our patches to net-ssh
|
13
|
+
require "vagrant/patches/net-ssh"
|
12
14
|
|
13
15
|
require "optparse"
|
14
16
|
|
@@ -79,7 +81,7 @@ if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
|
|
79
81
|
# See https://github.com/rest-client/rest-client/issues/34#issuecomment-290858
|
80
82
|
# for more information
|
81
83
|
class VagrantLogger < Log4r::Logger
|
82
|
-
def <<
|
84
|
+
def << msg
|
83
85
|
debug(msg.strip)
|
84
86
|
end
|
85
87
|
end
|
@@ -108,6 +108,14 @@ module Vagrant
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
is_error = is_metadata_results.find do |b|
|
112
|
+
b.is_a?(Errors::DownloaderError)
|
113
|
+
end
|
114
|
+
if is_error
|
115
|
+
raise Errors::BoxMetadataDownloadError,
|
116
|
+
message: is_error.extra_data[:message]
|
117
|
+
end
|
118
|
+
|
111
119
|
is_metadata = is_metadata_results.any? { |b| b === true }
|
112
120
|
if is_metadata && url.length > 1
|
113
121
|
raise Errors::BoxAddMetadataMultiURL,
|
@@ -118,7 +126,7 @@ module Vagrant
|
|
118
126
|
url = [url.first, authed_urls.first]
|
119
127
|
add_from_metadata(url, env, expanded)
|
120
128
|
else
|
121
|
-
add_direct(
|
129
|
+
add_direct(authed_urls, env)
|
122
130
|
end
|
123
131
|
|
124
132
|
@app.call(env)
|
@@ -538,11 +546,13 @@ module Vagrant
|
|
538
546
|
!!(match.last.chomp =~ /application\/json/)
|
539
547
|
end
|
540
548
|
|
541
|
-
def validate_checksum(checksum_type,
|
549
|
+
def validate_checksum(checksum_type, _checksum, path)
|
550
|
+
checksum = _checksum.strip()
|
542
551
|
@logger.info("Validating checksum with #{checksum_type}")
|
543
552
|
@logger.info("Expected checksum: #{checksum}")
|
544
553
|
|
545
|
-
|
554
|
+
_actual = FileChecksum.new(path, checksum_type).checksum
|
555
|
+
actual = _actual.strip()
|
546
556
|
@logger.info("Actual checksum: #{actual}")
|
547
557
|
if actual.casecmp(checksum) != 0
|
548
558
|
raise Errors::BoxChecksumMismatch,
|
@@ -46,7 +46,8 @@ module Vagrant
|
|
46
46
|
client_cert: env[:client_cert] ||
|
47
47
|
machine.config.vm.box_download_client_cert,
|
48
48
|
insecure: !env[:insecure].nil? ?
|
49
|
-
env[:insecure] : machine.config.vm.box_download_insecure
|
49
|
+
env[:insecure] : machine.config.vm.box_download_insecure,
|
50
|
+
box_extra_download_options: env[:box_extra_download_options] || machine.config.vm.box_extra_download_options,
|
50
51
|
}
|
51
52
|
|
52
53
|
env[:ui].output(I18n.t(
|
data/lib/vagrant/bundler.rb
CHANGED
@@ -189,8 +189,11 @@ module Vagrant
|
|
189
189
|
attr_reader :env_plugin_gem_path
|
190
190
|
# @return [Pathname] Vagrant environment data path
|
191
191
|
attr_reader :environment_data_path
|
192
|
+
# @return [Array<Gem::Specification>, nil] List of builtin specs
|
193
|
+
attr_accessor :builtin_specs
|
192
194
|
|
193
195
|
def initialize
|
196
|
+
@builtin_specs = []
|
194
197
|
@plugin_gem_path = Vagrant.user_data_path.join("gems", RUBY_VERSION).freeze
|
195
198
|
@logger = Log4r::Logger.new("vagrant::bundler")
|
196
199
|
end
|
@@ -287,7 +290,6 @@ module Vagrant
|
|
287
290
|
# Never allow dependencies to be remotely satisfied during init
|
288
291
|
request_set.remote = false
|
289
292
|
|
290
|
-
repair_result = nil
|
291
293
|
begin
|
292
294
|
@logger.debug("resolving solution from available specification set")
|
293
295
|
# Resolve the request set to ensure proper activation order
|
@@ -514,6 +516,9 @@ module Vagrant
|
|
514
516
|
@logger.debug("Enabling strict dependency enforcement")
|
515
517
|
plugin_deps += vagrant_internal_specs.map do |spec|
|
516
518
|
next if system_plugins.include?(spec.name)
|
519
|
+
# If this spec is for a default plugin included in
|
520
|
+
# the ruby stdlib, ignore it
|
521
|
+
next if spec.default_gem?
|
517
522
|
# If we are not running within the installer and
|
518
523
|
# we are not within a bundler environment then we
|
519
524
|
# only want activated specs
|
@@ -647,7 +652,6 @@ module Vagrant
|
|
647
652
|
self_spec.activate
|
648
653
|
@logger.info("Activated vagrant specification version - #{self_spec.version}")
|
649
654
|
end
|
650
|
-
self_spec.runtime_dependencies.each { |d| gem d.name, *d.requirement.as_list }
|
651
655
|
# discover all the gems we have available
|
652
656
|
list = {}
|
653
657
|
if Gem.respond_to?(:default_specifications_dir)
|
@@ -656,10 +660,16 @@ module Vagrant
|
|
656
660
|
spec_dir = Gem::Specification.default_specifications_dir
|
657
661
|
end
|
658
662
|
directories = [spec_dir]
|
659
|
-
|
660
|
-
|
663
|
+
if Vagrant.in_bundler?
|
664
|
+
Gem::Specification.find_all{true}.each do |spec|
|
665
|
+
list[spec.full_name] = spec
|
666
|
+
end
|
667
|
+
else
|
668
|
+
builtin_specs.each do |spec|
|
669
|
+
list[spec.full_name] = spec
|
670
|
+
end
|
661
671
|
end
|
662
|
-
if
|
672
|
+
if Vagrant.in_installer?
|
663
673
|
directories += Gem::Specification.dirs.find_all do |path|
|
664
674
|
!path.start_with?(Gem.user_dir)
|
665
675
|
end
|
data/lib/vagrant/environment.rb
CHANGED
@@ -517,6 +517,7 @@ module Vagrant
|
|
517
517
|
# @param [Action::Runner] action_runner A custom action runner for running hooks.
|
518
518
|
def hook(name, opts=nil)
|
519
519
|
@logger.info("Running hook: #{name}")
|
520
|
+
|
520
521
|
opts ||= {}
|
521
522
|
opts[:callable] ||= Action::Builder.new
|
522
523
|
opts[:runner] ||= action_runner
|
data/lib/vagrant/errors.rb
CHANGED
@@ -636,6 +636,18 @@ module Vagrant
|
|
636
636
|
error_key(:provisioner_winrm_unsupported)
|
637
637
|
end
|
638
638
|
|
639
|
+
class PluginNeedsDeveloperTools < VagrantError
|
640
|
+
error_key(:plugin_needs_developer_tools)
|
641
|
+
end
|
642
|
+
|
643
|
+
class PluginMissingLibrary < VagrantError
|
644
|
+
error_key(:plugin_missing_library)
|
645
|
+
end
|
646
|
+
|
647
|
+
class PluginMissingRubyDev < VagrantError
|
648
|
+
error_key(:plugin_missing_ruby_dev)
|
649
|
+
end
|
650
|
+
|
639
651
|
class PluginGemNotFound < VagrantError
|
640
652
|
error_key(:plugin_gem_not_found)
|
641
653
|
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require "net/ssh"
|
2
|
+
|
3
|
+
# Only patch if we have version 6.1.0 loaded as
|
4
|
+
# these patches pull 6.1.0 up to the as of now
|
5
|
+
# current 6.2.0 beta
|
6
|
+
if Net::SSH::Version::STRING == "6.1.0"
|
7
|
+
require "net/ssh/authentication/methods/publickey"
|
8
|
+
Net::SSH::Authentication::Methods::Publickey.class_eval do
|
9
|
+
def rsa_compat_build_request(pub_key, *args)
|
10
|
+
s_ver_str = session.transport.server_version.version.match(/OpenSSH_(?<version>\d+\.\d+)/)[:version]
|
11
|
+
begin
|
12
|
+
s_ver = Gem::Version.new(s_ver_str)
|
13
|
+
if s_ver >= Gem::Version.new("7.2") && pub_key.is_a?(OpenSSL::PKey::RSA)
|
14
|
+
pub_key.deprecated_ssh_rsa = true
|
15
|
+
debug { "public key has been marked for deprecated ssh-rsa SHA1 behavior" }
|
16
|
+
info = key_manager.known_identities[pub_key]
|
17
|
+
if info && info[:key]
|
18
|
+
info[:key].deprecated_ssh_rsa = true
|
19
|
+
debug { "private key has been marked for deprecated ssh-rsa SHA1 behavior" }
|
20
|
+
else
|
21
|
+
warn { "cannot deprecate ssh rsa on private key, not loaded (#{info[:file]})" }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
rescue ArgumentError
|
25
|
+
warn { "failed to parse OpenSSH version (raw: #{session.transport.server_version.version} attempted: #{s_ver_str}" }
|
26
|
+
end
|
27
|
+
_raw_build_request(pub_key, *args)
|
28
|
+
end
|
29
|
+
alias_method :_raw_build_request, :build_request
|
30
|
+
alias_method :build_request, :rsa_compat_build_request
|
31
|
+
end
|
32
|
+
|
33
|
+
require "net/ssh/authentication/agent"
|
34
|
+
# net/ssh/authentication/agent
|
35
|
+
Net::SSH::Authentication::Agent.class_eval do
|
36
|
+
SSH2_AGENT_LOCK = 22
|
37
|
+
SSH2_AGENT_UNLOCK = 23
|
38
|
+
|
39
|
+
# lock the ssh agent with password
|
40
|
+
def lock(password)
|
41
|
+
type, = send_and_wait(SSH2_AGENT_LOCK, :string, password)
|
42
|
+
raise AgentError, "could not lock agent" if type != SSH_AGENT_SUCCESS
|
43
|
+
end
|
44
|
+
|
45
|
+
# unlock the ssh agent with password
|
46
|
+
def unlock(password)
|
47
|
+
type, = send_and_wait(SSH2_AGENT_UNLOCK, :string, password)
|
48
|
+
raise AgentError, "could not unlock agent" if type != SSH_AGENT_SUCCESS
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
require "net/ssh/authentication/certificate"
|
53
|
+
# net/ssh/authentication/certificate
|
54
|
+
Net::SSH::Authentication::Certificate.class_eval do
|
55
|
+
def ssh_do_verify(sig, data, options = {})
|
56
|
+
key.ssh_do_verify(sig, data, options)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
require "net/ssh/authentication/ed25519"
|
61
|
+
# net/ssh/authentication/ed25519
|
62
|
+
Net::SSH::Authentication::ED25519::PubKey.class_eval do
|
63
|
+
def ssh_do_verify(sig, data, options = {})
|
64
|
+
@verify_key.verify(sig,data)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
require "net/ssh/transport/algorithms"
|
69
|
+
# net/ssh/transport/algorithms
|
70
|
+
Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[:host_key].push("rsa-sha2-256").push("rsa-sha2-512")
|
71
|
+
|
72
|
+
require "net/ssh/transport/cipher_factory"
|
73
|
+
# net/ssh/transport/cipher_factory
|
74
|
+
Net::SSH::Transport::CipherFactory::SSH_TO_OSSL["aes256-ctr"] = ::OpenSSL::Cipher.ciphers.include?("aes-256-ctr") ? "aes-256-ctr" : "aes-256-ecb"
|
75
|
+
Net::SSH::Transport::CipherFactory::SSH_TO_OSSL["aes192-ctr"] = ::OpenSSL::Cipher.ciphers.include?("aes-192-ctr") ? "aes-192-ctr" : "aes-192-ecb"
|
76
|
+
Net::SSH::Transport::CipherFactory::SSH_TO_OSSL["aes128-ctr"] = ::OpenSSL::Cipher.ciphers.include?("aes-128-ctr") ? "aes-128-ctr" : "aes-128-ecb"
|
77
|
+
|
78
|
+
require "net/ssh/transport/kex/abstract"
|
79
|
+
# net/ssh/transport/kex/abstract
|
80
|
+
Net::SSH::Transport::Kex::Abstract.class_eval do
|
81
|
+
def matching?(key_ssh_type, host_key_alg)
|
82
|
+
return true if key_ssh_type == host_key_alg
|
83
|
+
return true if key_ssh_type == 'ssh-rsa' && ['rsa-sha2-512', 'rsa-sha2-256'].include?(host_key_alg)
|
84
|
+
end
|
85
|
+
|
86
|
+
def verify_server_key(key) #:nodoc:
|
87
|
+
unless matching?(key.ssh_type, algorithms.host_key)
|
88
|
+
raise Net::SSH::Exception, "host key algorithm mismatch '#{key.ssh_type}' != '#{algorithms.host_key}'"
|
89
|
+
end
|
90
|
+
|
91
|
+
blob, fingerprint = generate_key_fingerprint(key)
|
92
|
+
|
93
|
+
unless connection.host_key_verifier.verify(key: key, key_blob: blob, fingerprint: fingerprint, session: connection)
|
94
|
+
raise Net::SSH::Exception, 'host key verification failed'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def verify_signature(result) #:nodoc:
|
99
|
+
response = build_signature_buffer(result)
|
100
|
+
|
101
|
+
hash = digester.digest(response.to_s)
|
102
|
+
|
103
|
+
server_key = result[:server_key]
|
104
|
+
server_sig = result[:server_sig]
|
105
|
+
unless connection.host_key_verifier.verify_signature { server_key.ssh_do_verify(server_sig, hash, host_key: algorithms.host_key) }
|
106
|
+
raise Net::SSH::Exception, 'could not verify server signature'
|
107
|
+
end
|
108
|
+
|
109
|
+
hash
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
require "net/ssh/transport/openssl"
|
114
|
+
# net/ssh/transport/openssl
|
115
|
+
OpenSSL::PKey::RSA.class_eval do
|
116
|
+
attr_accessor :deprecated_ssh_rsa
|
117
|
+
|
118
|
+
def ssh_do_verify(sig, data, options = {})
|
119
|
+
digester =
|
120
|
+
if options[:host_key] == "rsa-sha2-512"
|
121
|
+
OpenSSL::Digest::SHA512.new
|
122
|
+
elsif options[:host_key] == "rsa-sha2-256"
|
123
|
+
OpenSSL::Digest::SHA256.new
|
124
|
+
else
|
125
|
+
OpenSSL::Digest::SHA1.new
|
126
|
+
end
|
127
|
+
|
128
|
+
verify(digester, sig, data)
|
129
|
+
end
|
130
|
+
|
131
|
+
def ssh_type
|
132
|
+
deprecated_ssh_rsa ? signature_algorithm : "ssh-rsa"
|
133
|
+
end
|
134
|
+
|
135
|
+
def signature_algorithm
|
136
|
+
"rsa-sha2-256"
|
137
|
+
end
|
138
|
+
|
139
|
+
def ssh_do_sign(data)
|
140
|
+
if deprecated_ssh_rsa
|
141
|
+
sign(OpenSSL::Digest::SHA256.new, data)
|
142
|
+
else
|
143
|
+
sign(OpenSSL::Digest::SHA1.new, data)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
OpenSSL::PKey::DSA.class_eval do
|
149
|
+
def ssh_do_verify(sig, data, options = {})
|
150
|
+
sig_r = sig[0,20].unpack("H*")[0].to_i(16)
|
151
|
+
sig_s = sig[20,20].unpack("H*")[0].to_i(16)
|
152
|
+
a1sig = OpenSSL::ASN1::Sequence([
|
153
|
+
OpenSSL::ASN1::Integer(sig_r),
|
154
|
+
OpenSSL::ASN1::Integer(sig_s)
|
155
|
+
])
|
156
|
+
return verify(OpenSSL::Digest::SHA1.new, a1sig.to_der, data)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
OpenSSL::PKey::EC.class_eval do
|
161
|
+
def ssh_do_verify(sig, data, options = {})
|
162
|
+
digest = digester.digest(data)
|
163
|
+
a1sig = nil
|
164
|
+
|
165
|
+
begin
|
166
|
+
sig_r_len = sig[0, 4].unpack('H*')[0].to_i(16)
|
167
|
+
sig_l_len = sig[4 + sig_r_len, 4].unpack('H*')[0].to_i(16)
|
168
|
+
|
169
|
+
sig_r = sig[4, sig_r_len].unpack('H*')[0]
|
170
|
+
sig_s = sig[4 + sig_r_len + 4, sig_l_len].unpack('H*')[0]
|
171
|
+
|
172
|
+
a1sig = OpenSSL::ASN1::Sequence([
|
173
|
+
OpenSSL::ASN1::Integer(sig_r.to_i(16)),
|
174
|
+
OpenSSL::ASN1::Integer(sig_s.to_i(16))
|
175
|
+
])
|
176
|
+
rescue StandardError
|
177
|
+
end
|
178
|
+
|
179
|
+
if a1sig.nil?
|
180
|
+
return false
|
181
|
+
else
|
182
|
+
dsa_verify_asn1(digest, a1sig.to_der)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|