启动 Vagrantbox 时出现 Openssl 3.0 错误

Openssl 3.0 error when booting Vagrantbox

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

现在我最重要的 vagrantbox 出了问题。这个盒子封装了我的开发环境。我想我可以在全新安装后启动这个盒子,然后一切都按照我习惯的方式工作。现在我 运行 遇到 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 20.04 上一切正常。

  1. 前往 here 并下载最新的 .deb 版本(不要使用存储库!向下滚动到页面底部)
  2. 确保删除之前安装的 vagrant:sudo apt purge vagrantsudo apt autoremove
  3. 同时删除之前安装的 vagrant 添加的密钥:sudo apt-key list 找到 hashicorp 密钥并将其删除:sudo apt-key del "E8A0 32E0 94D8 EB4E A189 D270 DA41 8C88 A321 9F7B" 密钥可能与您的情况不同。
  4. 同时删除之前安装的 vagrant 添加的存储库:sudo ls /etc/apt/sources.list.d 找到存储库并将其删除:sudo rm /etc/apt/sources.list.d/archive_uri-https_apt_releases_hashicorp_com-jammy.list
  5. 打开一个终端和 CD 到你下载它的地方,例如:cd /Downloads
  6. 运行 以下命令(注意 您的包名称可能会 不同):sudo dpkg -i vagrant_2.2.19_i686.debsudo dpkg -i vagrant_2.2.19_x86_64.deb

您可能必须先 vagrant destroy 您当前的 VM,然后再 vagrant up

希望你的问题已经解决了。

此解决方案的所有功劳归功于这些人 here