使用准系统自定义程序包使用vagrant时身份验证失败

时间:2017-08-26 19:30:40

标签: authentication vagrant package

我是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 Install。当我尝试从自定义包中创建一个新框时,我的问题出现了。

我创建了一个新目录并使用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时,我会在VM启动后重复this output。关键段落似乎是:

 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.>

在打包自定义文件夹之前,我需要做些什么,以便任何开发人员都可以使用它而无需在公钥和私钥上执行任何伏都教?

1 个答案:

答案 0 :(得分: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