无法使用不安全的私钥(vagrant 1.7.2)ssh 到流浪虚拟机 [英] Can't ssh to vagrant VMs using the insecure private key (vagrant 1.7.2)

查看:35
本文介绍了无法使用不安全的私钥(vagrant 1.7.2)ssh 到流浪虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由 3 个虚拟机组成的集群.这是 Vagrantfile:

I have a cluster of 3 VMs. Here is the Vagrantfile:

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


hosts = {
  "host0" => "192.168.33.10",
  "host1" => "192.168.33.11",
  "host2" => "192.168.33.12"
}

Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
  config.ssh.private_key_path = File.expand_path('~/.vagrant.d/insecure_private_key')

  hosts.each do |name, ip|
    config.vm.define name do |machine|
      machine.vm.hostname = "%s.example.org" % name
      machine.vm.network :private_network, ip: ip
      machine.vm.provider "virtualbox" do |v|
          v.name = name
      #    #v.customize ["modifyvm", :id, "--memory", 200]
      end
    end
  end
end

这在我最近升级之前一直有效:

This used to work until I upgraded recently:

ssh -i ~/.vagrant.d/insecure_private_key vagrant@192.168.33.10

相反,vagrant 要求输入密码.

Instead, vagrant asks for a password.

似乎最近版本的 vagrant(我使用的是 1.7.2)为每台机器创建了一个安全的私钥.我通过运行发现它

It seems that recent versions of vagrant (I'm on 1.7.2) create a secure private key for each machine. I discovered it by running

vagrant ssh-config

输出显示每个主机的不同密钥.我通过比较它们来验证密钥是不同的.

The output shows different keys for each host. I verified the keys are different by diffing them.

我试图通过在 Vagrantfile 中设置 config.ssh.private_key_path 来强制使用不安全的密钥,但它不起作用.

I tried to force the insecure key by setting in Vagrantfile the config.ssh.private_key_path, but it doesn't work.

我想对所有机器使用不安全密钥的原因是我想使用 ansible 从外部配置它们.我不想使用 Ansible 配置器,而是将 VM 视为远程服务器.所以,Vagrantfile 只是用来指定集群中的机器,然后在外部进行配置.

The reason I want to use the insecure key for all machines is that I want to provision them from the outside using ansible. I don't want to use the Ansible provisioner, but treat the VMs as remote servers. So, the Vagrantfile is just used to specify the machines in the cluster and then provisioning will be done externally.

文档仍然说默认情况下机器将使用不安全的私钥.

The documentation still says that by default machines will use the insecure private key.

如何让我的虚拟机使用不安全的私钥?

How can I make my VMs use the insecure private key?

推荐答案

Vagrant 在 1.6 和 1.7 版本之间改变了行为,现在将插入自动生成的不安全密钥而不是默认密钥.

Vagrant changed the behaviour between 1.6 and 1.7 versions and now will insert auto generated insecure key instead of the default one.

您可以通过在 Vagrantfile 中设置 config.ssh.insert_key = false 来取消此行为.

You can cancel this behaviour by setting config.ssh.insert_key = false in your Vagrantfile.

如果您像您一样指定 private_key_path,Vagrant 不应替换不安全的密钥,但是内部逻辑会检查 private_key_path 是否指向默认的 insecure_private_key,如果是,Vagrant 将替换它.

Vagrant shouldn't replace insecure key if you specify private_key_path like you did, however the internal logic checks if the private_key_path points to the default insecure_private_key, and if it does, Vagrant will replace it.

可以在此处找到更多信息.

这篇关于无法使用不安全的私钥(vagrant 1.7.2)ssh 到流浪虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆