【问题标题】:Authentication failure when using vagrant up with a barebones custom package将 vagrant up 与准系统自定义包一起使用时身份验证失败
【发布时间】:2017-08-27 16:56:24
【问题描述】:

我是 Vagrant 的新手,所以我正在采取一些小步骤来确保我理解这个过程。我想确保在我开始在虚拟机中进行任何认真的开发之前,我可以创建一个自定义包。目前,我只是简单地使用了官方的ubuntu/xenial64 Vagrant box,并配置它以便安装 nginx。你可以找到my step-by-step guide to this here

我的定制盒子工作正常。我使用vagrant package --output nginx.box 然后vagrant box add nginx nginx.box 将我的自定义框添加到我的Vagrant 安装中。当我尝试从自定义包创建一个新盒子时,我的问题就出现了。

我创建了一个新目录并使用vagrant init nginx 来创建我的自定义框的克隆,但是当我使用vagrant up 时,Vagrant 无法 验证:

  ==> 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 reset. Retrying...
  default: Warning: Remote connection disconnect. Retrying...
  default: Warning: Connection reset. Retrying...
  default: Warning: Remote connection disconnect. Retrying...
  default: Warning: Connection reset. Retrying...
  default: Warning: Remote connection disconnect. Retrying...
  default: Warning: Connection reset. Retrying...
  default: Warning: Remote connection disconnect. Retrying...
  default: Warning: Connection reset. Retrying...
  default: Warning: Remote connection disconnect. Retrying...
  default: Warning: Authentication failure. Retrying...
  default: Warning: Authentication failure. Retrying...
  default: Warning: Authentication failure. Retrying...

如果我通过 VirtualBox Manager 连接到 VM,系统会要求我进行身份验证,并且使用登录名和密码“vagrant”失败。

我查看了描述类似症状的 this questionthis other question,但我还没有在答案中找到解决问题的方法。当我运行vagrant up --debug 时,我得到this output 在VM 启动后重复。关键段落似乎是:

 DEBUG ssh: == Net-SSH connection debug-level log END ==
 INFO ssh: SSH not ready: #<Vagrant::Errors::SSHAuthenticationFailed:
 SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.>

在我打包我的自定义盒子之前我需要做什么,这样任何开发者都可以使用它,而无需对公钥和私钥执行任何巫术?

【问题讨论】:

    标签: authentication vagrant package


    【解决方案1】:

    这个盒子是密码认证的,当你安装盒子时,你可以检查它的 Vagrantfile 的密码(在我的 Mac 上,我会在 ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20170116.1.0/virtualbox 看到文件)

    config.ssh.username = "ubuntu"
    config.ssh.password = "95bf98670a543bcd7bdd576c"
    

    当你构建你自己的盒子时,最简单的方法可能是重新打包这个相同的文件(参见https://www.vagrantup.com/docs/cli/package.html#vagrantfile-file),所以在你的步骤中

    重新包装成一个新的 Vagrant Box:

    vagrant package --output nginx.box

    我会跑

    vagrant package --vagrantfile <path_to_original_box_vagrantfile> --output nginx.box
    

    【讨论】:

    • 谢谢。这样可行。 vagrant up 现在运行完成。但是vagrant ssh 仍然会导致问题。我已经为其他问题创建了一个new question
    猜你喜欢
    • 1970-01-01
    • 2014-05-20
    • 2016-10-18
    • 1970-01-01
    • 2016-01-26
    • 2021-11-19
    • 2020-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多