启动 Vagrantbox 时出现 Openssl 3.0 错误

启动 Vagrantbox 时出现 Openssl 3.0 错误

我将本地 Linux 笔记本从 Ubuntu 20.04 更新到了 22.04。出于多种原因,我进行了全新安装。

现在我最重要的 vagrantbox 出现了问题。这个 box 封装了我的开发环境。我以为我可以在全新安装后启动这个 box,然后一切都会按照我习惯的方式运行。现在我遇到了 OpenSSL 3.0 错误,它破坏了 VM 配置。我运行了 start.sh,它基本上调用了vagrant validatevagrant box updatevagrant up。所以没什么特别的。

这是我的 Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

IMAGE_NAME = "ubuntu/jammy64" # impish = 21.10 | jammy = 22.04 | bento/ubuntu-21.10
HOSTNAME = "pegasus"
#IP="10.42.10.10"

Vagrant.configure(2) do |config|

    #
    # Vagrantbox: pegasus
    #
    config.vm.define HOSTNAME do |pegasus|
        pegasus.vm.box = IMAGE_NAME
        pegasus.vm.hostname = HOSTNAME
        #pegasus.vm.network :private_network, ip: IP

        if Vagrant.has_plugin?("vagrant-cachier")
            pegasus.cache.scope = :box # Configure cached packages to be shared between instances of the same base box
        end

        pegasus.vm.provider "virtualbox" do |v|
            v.memory = 1024*6
            v.cpus = 2
            v.customize ["modifyvm", :id, "--groups", "/vagrantboxes"]
            # v.customize ["modifyvm", :id, "--ioapic", "on"] # https://www.mkwd.net/improve-vagrant-performance/
            v.name = HOSTNAME
        end

        # copy files and mount shared volumes
        pegasus.ssh.forward_agent = true # If true, agent forwarding over SSH connections is enabled. Defaults to false.
        pegasus.vm.provision "file", source: "~/.ssh", destination: "/home/vagrant/.ssh"
        pegasus.vm.synced_folder "~/tmp", "/home/vagrant/tmp"
        pegasus.vm.synced_folder "~/work", "/home/vagrant/work"

        # provisioning
        pegasus.vm.provision "shell", :inline => "sudo rm /etc/localtime && sudo ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime", run: "always"
        pegasus.vm.provision "shell", path: "provision/install/uninstall.sh"
        pegasus.vm.provision "shell", path: "provision/configure.sh"
        pegasus.vm.provision "shell", path: "provision/ssh-keys.sh", privileged: false # Use default user (vagrant) instead of root
        pegasus.vm.provision :docker
        pegasus.vm.provision "shell", path: "docker/images/build-images.sh"
        pegasus.vm.provision :docker_compose, yml: "/vagrant/docker/services/ops/docker-compose.yml", run: "always"
        pegasus.vm.provision :docker_compose, yml: "/vagrant/docker/services/services/docker-compose.yml", run: "always"
        pegasus.vm.provision "shell", path: "provision/install/update-upgrade.sh"
        pegasus.vm.provision "shell", path: "provision/install/basic-packages.sh"
        pegasus.vm.provision "shell", path: "provision/install/java.sh"
        pegasus.vm.provision "shell", path: "provision/install/node.sh"
        pegasus.vm.provision "shell", path: "initialize/rundeck/init.sh"

        # in use -> see src/main/vagrantboxes/pegasus/docker/services/docker-compose.yml
        pegasus.vm.network "forwarded_port", host: 7100, guest: 9100
        pegasus.vm.network "forwarded_port", host: 7110, guest: 7110
        pegasus.vm.network "forwarded_port", host: 7440, guest: 7440
        pegasus.vm.network "forwarded_port", host: 7990, guest: 7990

        # prepared
        pegasus.vm.network "forwarded_port", host: 7000, guest: 7000 # free
        pegasus.vm.network "forwarded_port", host: 7080, guest: 7080 # free
        pegasus.vm.network "forwarded_port", host: 7081, guest: 7081 # free
        pegasus.vm.network "forwarded_port", host: 7443, guest: 7443 # free
        pegasus.vm.network "forwarded_port", host: 7888, guest: 7888 # pegasus/website & pegasus/docs-website
    end
end

每次我在新安装的 Ubuntu 上启动这个框时都会遇到这个错误:

[INFO] Startup
Bringing machine 'pegasus' up with 'virtualbox' provider...
==> pegasus: Importing base box 'ubuntu/jammy64'...
==> pegasus: Matching MAC address for NAT networking...
==> pegasus: Checking if box 'ubuntu/jammy64' version '20220423.0.0' is up to date...
==> pegasus: Setting the name of the VM: pegasus
==> pegasus: Clearing any previously set network interfaces...
==> pegasus: Preparing network interfaces based on configuration...
    pegasus: Adapter 1: nat
==> pegasus: Forwarding ports...
    pegasus: 9100 (guest) => 7100 (host) (adapter 1)
    pegasus: 7110 (guest) => 7110 (host) (adapter 1)
    pegasus: 7440 (guest) => 7440 (host) (adapter 1)
    pegasus: 7990 (guest) => 7990 (host) (adapter 1)
    pegasus: 7000 (guest) => 7000 (host) (adapter 1)
    pegasus: 7080 (guest) => 7080 (host) (adapter 1)
    pegasus: 7081 (guest) => 7081 (host) (adapter 1)
    pegasus: 7443 (guest) => 7443 (host) (adapter 1)
    pegasus: 7888 (guest) => 7888 (host) (adapter 1)
    pegasus: 22 (guest) => 2222 (host) (adapter 1)
==> pegasus: Running 'pre-boot' VM customizations...
==> pegasus: Booting VM...
==> pegasus: Waiting for machine to boot. This may take a few minutes...
    pegasus: SSH address: 127.0.0.1:2222
    pegasus: SSH username: vagrant
    pegasus: SSH auth method: private key
    pegasus: Warning: Remote connection disconnect. Retrying...
    pegasus: Warning: Connection reset. Retrying...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
==> pegasus: Attempting graceful shutdown of VM...
/usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb:21:in `generate_key!': pkeys are immutable on OpenSSL 3.0 (OpenSSL::PKey::PKeyError)
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb:21:in `generate_key'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/kex/abstract.rb:32:in `initialize'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/algorithms.rb:437:in `new'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/algorithms.rb:437:in `exchange_keys'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/algorithms.rb:245:in `proceed!'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/algorithms.rb:184:in `accept_kexinit'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:210:in `block in poll_message'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:190:in `loop'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:190:in `poll_message'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:225:in `block in wait'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:223:in `loop'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:223:in `wait'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh/transport/session.rb:90:in `initialize'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh.rb:251:in `new'
    from /usr/share/rubygems-integration/all/gems/net-ssh-6.1.0/lib/net/ssh.rb:251:in `start'
    from /usr/share/rubygems-integration/all/gems/vagrant-2.2.19/plugins/communicators/ssh/communicator.rb:467:in `block (2 levels) in connect'
    from /usr/lib/ruby/3.0.0/timeout.rb:97:in `block in timeout'
    from /usr/lib/ruby/3.0.0/timeout.rb:35:in `block in catch'
    from /usr/lib/ruby/3.0.0/timeout.rb:35:in `catch'
    from /usr/lib/ruby/3.0.0/timeout.rb:35:in `catch'
    from /usr/lib/ruby/3.0.0/timeout.rb:112:in `timeout'

我缩短了堆栈跟踪以提高可读性。实际消息要长得多。

我的环境包括

  • Ubuntu 22.04
  • 内核 5.15.0-25-通用
  • Virtualbox 6.1.32_Ubuntu r149290
  • Vagrant 2.2.19

有人知道我该如何修复这个错误吗?正如我所说,在我的旧 Ubuntu 20.04 上一切都运行正常。


更新我刚刚尝试启动一个新的 vagrantbox。非常简单。同样的错误。

# -*- mode: ruby -*-
# vi: set ft=ruby :

IMAGE_NAME = "ubuntu/jammy64" # jammy = 22.04
HOSTNAME = "ubuntu-cloud-init"

Vagrant.configure(2) do |config|
    config.vm.box = IMAGE_NAME
    config.vm.hostname = HOSTNAME

    config.vm.provider "virtualbox" do |v|
        v.memory = 2048
        v.cpus = 2
        v.customize ["modifyvm", :id, "--groups", "/vagrantboxes"]
        v.name = HOSTNAME
    end

    config.vm.provision "shell", path: "provision/configure.sh"
    config.vm.provision "shell", path: "provision/install/update-upgrade.sh"
    config.vm.provision "shell", path: "provision/install/basic-packages.sh"
end

答案1

按照建议安装https://www.vagrantup.com/downloads不起作用

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant

但是手动安装 Debian 软件包是可行的:

sudo apt-get remove vagrant
# this will remove the packages vagrant and vagrant-libvirt
sudo dpkg -i vagrant_2.2.19_i686.deb

真的很奇怪!!! 也许卸载该软件包很重要vagrant-libvirt

有关此问题的更多更新信息请参见此处:https://github.com/hashicorp/vagrant/issues/12751

答案2

TLDR;升级到 Ruby 2.7 以及 vagrant 的最新版本依赖项。


有人知道我该如何修复这个错误吗?正如我所说,在我的旧 Ubuntu 20.04 上一切都运行正常。

一般来说:修复 Ruby 2.6 的 net-ssh 包或升级到 Ruby 2.7。

在 Gentoo 上,这对我来说很有效(2022-05)。

允许“测试”或“不稳定”版本的软件包后:

$ emerge app-emulation/vagrant -1va 

These are the packages that would be merged, in order:

Calculating dependencies  ..... done!
[ebuild   R    ] dev-ruby/log4r-1.1.10-r3::gentoo  USE="-doc -test" RUBY_TARGETS="ruby26 ruby27* (-ruby30)" 0 KiB
[ebuild   R    ] dev-ruby/ed25519-1.2.4-r1:1::gentoo  USE="-doc -test" RUBY_TARGETS="ruby26 ruby27* (-ruby30)" 0 KiB
[ebuild     U ~] dev-ruby/vagrant_cloud-3.0.5::gentoo [3.0.2::gentoo] USE="-doc -test" RUBY_TARGETS="ruby26 ruby27* -ruby30%" 35 KiB
[ebuild     U ~] app-emulation/vagrant-2.2.18-r1::gentoo [2.2.9-r1::gentoo] USE="-test (-virtualbox%*)" RUBY_TARGETS="ruby26 ruby27%*" 1,583 KiB

Total: 4 packages (2 upgrades, 2 reinstalls), Size of downloads: 1,617 KiB

Would you like to merge these packages? [Yes/No] Yes
>>> Verifying ebuild manifests
>>> Emergink (1 of 4) dev-ruby/log4r-1.1.10-r3::gentoo
>>> Emergink (2 of 4) dev-ruby/ed25519-1.2.4-r1::gentoo
>>> Instlink (1 of 4) dev-ruby/log4r-1.1.10-r3::gentoo
>>> Emergink (3 of 4) dev-ruby/vagrant_cloud-3.0.5::gentoo
>>> Instlink (2 of 4) dev-ruby/ed25519-1.2.4-r1::gentoo
>>> Instlink (3 of 4) dev-ruby/vagrant_cloud-3.0.5::gentoo
>>> Emergink (4 of 4) app-emulation/vagrant-2.2.18-r1::gentoo
>>> Instlink (4 of 4) app-emulation/vagrant-2.2.18-r1::gentoo
(...)

然后刷新 vagrant 的插件(阅读它向您发出的警告)。

$ vagrant plugin expunge --reinstall

Continue? [N]: Y

All user installed plugins have been removed from this Vagrant environment!

Vagrant will now attempt to reinstall user plugins that were removed.
(...)
Installed the plugin 'vagrant-disksize (0.1.3)'!
Installed the plugin 'vagrant-vbguest (0.30.0)'!

现在向上:

$ vagrant up
(...)
==> pegasus: Successfully added box 'ubuntu/jammy64' (v20220423.0.0) for 'virtualbox'!
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The host path of the shared folder is missing: ~/work
* The 'docker_compose' provisioner could not be found.
* The 'docker_compose' provisioner could not be found.
(...)

相关内容