添加 -o KexAlgorithms 到 vagrant up 的 ssh

添加 -o KexAlgorithms 到 vagrant up 的 ssh

我想使用:https://app.vagrantup.com/FritsHoogland/boxes/centos39-oracle817

基本vagrant up命令失败:

$ vagrant init FritsHoogland/centos39-oracle817
$ vagrant up
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "0e84ac28-6e1d-432a-b417-cc99c71562b7", "--type", "headless"]

Stderr: VBoxManage: error: Implementation of the USB 2.0 controller not found!
VBoxManage: error: Because the USB 2.0 controller state is part of the saved VM state, the VM cannot be started. To fix this problem, either install the 'Oracle VM VirtualBox Extension Pack' or disable USB 2.0 support in the VM settings.
VBoxManage: error: Note! This error could also mean that an incompatible version of the 'Oracle VM VirtualBox Extension Pack' is installed (VERR_NOT_FOUND)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

我编辑 Vagrantfile 以忽略 USB 错误:

  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--usb", "on"]
    vb.customize ["modifyvm", :id, "--usbehci", "off"]
  end

这会启动 VM,但到 VM 的初始 ssh 失败:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'FritsHoogland/centos39-oracle817'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'FritsHoogland/centos39-oracle817' version '0.0.2' is up to date...
==> default: Setting the name of the VM: c_default_1689909952468_41
==> default: Fixed port collision for 22 => 2222. Now on port 2206.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2206 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2206
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

Vagrant 似乎正在运行:

/usr/bin/ssh -vv -p 2206 -o LogLevel=FATAL -o Compression=yes -o DSAAuthentication=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o KexAlgorithms=+diffie-hellman-group1-sha1 -o UserKnownHostsFile=/dev/null -i /home/tange/.vagrant.d/insecure_private_key [email protected]

这失败了。

我怎样才能让它添加-o KexAlgorithms=+diffie-hellman-group1-sha1看起来有效的功能:

/usr/bin/ssh -vv -p 2206 -o LogLevel=FATAL -o Compression=yes -o DSAAuthentication=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o KexAlgorithms=+diffie-hellman-group1-sha1 -o UserKnownHostsFile=/dev/null -i /home/tange/.vagrant.d/insecure_private_key [email protected]

这将登录到虚拟机。

我尝试将其添加到〜/.ssh/config:

Host *
  KexAlgorithms +diffie-hellman-group1-sha1

但最初vagrant up似乎忽略了这一点。

我添加到 Vagrantfile 中:

config.ssh.extra_args = ["-o" "KexAlgorithms=+diffie-hellman-group1-sha1"]

这似乎被使用vagrant ssh但不是被使用vagrant up。换句话说:vagrant up挂起,但vagrant ssh在系统启动后工作。

Vagrantfile 是否有我可以设置的部分-o KexAlgorithms +diffie-hellman-group1-sha1或其他方式来vagrant up使用它?

相关内容