我可以让 Vagrant 保留不安全的密钥吗?

我可以让 Vagrant 保留不安全的密钥吗?

似乎 Vagrant 在检测到不安全的密钥对时会生成新的密钥对。是否可以阻止这种行为?

答案1

是的

# By default, Vagrant 1.7+ automatically inserts a different
# insecure keypair for each new VM created. The easiest way
# to use the same keypair for all the machines is to disable
# this feature and rely on the legacy insecure key.
config.ssh.insert_key = false

例如...我当前的“快速测试” Vagrantfile 如下所示:

C:\Users\monsterkill\vagrant>cat Vagrantfile
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.ssh.insert_key = false
        config.vm.define "vagrant1" do |vagrant1|
                vagrant1.vm.box = "ubuntu/trusty64"
                vagrant1.vm.network "forwarded_port", guest: 80, host: 8080
                vagrant1.vm.network "forwarded_port", guest: 443, host: 8443
                vagrant1.vm.network "private_network", ip: "192.168.33.10"
        end
end

答案2

是的,通过添加这一行config.ssh.insert_key = false

以下是示例:

Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty64"
  config.ssh.insert_key = false

end

相关内容