我已经为 python dev 设置了第一个 Vagrant 框,它运行良好。我可以vagrant ssh
毫无问题地放入原装盒子中。
当我尝试创建该盒子的副本(使用vagrant package
)并与同事共享时,问题就开始了。当我尝试使用启动该副本时,我遇到了经常报告的 ssh 身份验证失败。请注意,我仍然可以在原始盒子中vagrant up
使用。vagrant ssh
工作流程和日志
vagrant_anaconda ==> 我的基本框
newvm ==> 副本
包创建
cd vagrant
vagrant up (doc says the VM should be running)
vagrant package --base vagrant_anaconda --output ~/Code/vagrant.box --vagrantfile Vagrantfile --include bootstrap.sh
新 Vagrant VM 设置
mkdir newvm
cd newvm
vagrant init newvm ~/Code/vagrant.box
我复制了原始 vm 的 bootstrap.sh(include 参数可能不应该用于此)
Vagrantfile(为简洁起见删除了注释)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "chef/centos-6.5"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 5002, host: 5002
end
引导程序
#!/usr/bin/env bash
yum update
yum -y install httpd
rm -rf /var/www/html
ln -fs /vagrant /var/www/html
service httpd start
可怕的 SSH 身份验证错误
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'newvm'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: newvm_default_1425211273763_74431
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 8080 (adapter 1)
default: 5002 => 5002 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
的结果vagrant ssh-config
:
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/nicolas/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
采取的步骤:
如果我启动 VM 的 GUI(如其他答案中所建议的),我可以看到它正在请求登录/psw。
我尝试删除 insecure_private_key。没有效果。
我如何登录我的第二个邮箱?我如何才能合理地确保我要发送邮件的人不会遇到这个问题?