Pyr*_*bie 35 ssh vagrant vagrantfile
我有一个3个VM的集群.这是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
Run Code Online (Sandbox Code Playgroud)
这曾经工作,直到我最近升级:
ssh -i ~/.vagrant.d/insecure_private_key vagrant@192.168.33.10
Run Code Online (Sandbox Code Playgroud)
相反,vagrant要求输入密码.
似乎最近版本的vagrant(我在1.7.2上)为每台机器创建了一个安全的私钥.我通过跑步发现了它
vagrant ssh-config
Run Code Online (Sandbox Code Playgroud)
输出显示每个主机的不同密钥.我通过区分它们来验证键是不同的.
我试图通过在Vagrantfile中设置config.ssh.private_key_path来强制不安全的密钥,但它不起作用.
我想为所有机器使用不安全密钥的原因是我想使用ansible从外部配置它们.我不想使用Ansible配置器,但将VM视为远程服务器.因此,Vagrantfile仅用于指定群集中的计算机,然后配置将在外部完成.
文档仍然说默认情况下机器将使用不安全的私钥.
如何让我的VM使用不安全的私钥?
aba*_*abo 21
当Vagrant创建一个新的ssh密钥时,它将使用默认配置保存在Vagrantfile目录下的.vagrant/machines/default/virtualbox/private_key中.
使用自动生成的密钥,您可以使用与Vagrantfile相同的目录登录,如下所示:
ssh -i .vagrant/machines/default/virtualbox/private_key -p 2222 vagrant@localhost
Run Code Online (Sandbox Code Playgroud)
要了解有关vagrant box的实际ssh配置的所有详细信息,请使用vagrant ssh-config命令.
# vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/babo/src/centos/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
Run Code Online (Sandbox Code Playgroud)
And*_*ndy 13
添加config.ssh.insert_key = false到Vagrantfile并删除新的vm私钥.vagrant/machines/default/virtualbox/private_key流浪者会自动vagrant ssh-config使用正确的私钥进行更新~/.vagrant.d/insecure_private_key.我要做的最后一件事是ssh进入vm并更新vm上的授权密钥文件.curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub > ~/.ssh/authorized_keys
| 归档时间: |
|
| 查看次数: |
63686 次 |
| 最近记录: |