无法在自定义框

时间:2017-08-27 10:06:48

标签: ssh vagrant

我已根据the official ubuntu/xenial64 Vagrant box成功创建了一个自定义Vagrant框,但是当我尝试使用vagrant ssh时收到此消息:

==> default: The machine you're attempting to SSH into is configured to use
==> default: password-based authentication. Vagrant can't script entering the
==> default: password for you. If you're prompted for a password, please enter
==> default: the same password you have configured in the Vagrantfile.

该框的唯一变化是使用NginX进行配置。然后我用...

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

...其中<path_to_vagrantfile>就我而言/home/blackslate/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20170822.0.0/virtualbox/Vagrantfile。我跟着这个:

vagrant box add nginx nginx.box

然后我创建一个新目录并使用vagrant init nginx创建该框的新实例。整个过程在this question中描述。

当我使用vagrant up时,所有内容似乎都按预期运行:

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'nginx'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: Custom_default_1503826905856_10643
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: ubuntu
    default: SSH auth method: password
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /home/blackslate/repos/Vagrant/Custom

然而,vagrant ssh在这个问题的开头引发了这个消息。当我尝试手动ssh时,使用“ubuntu”作为ssh用户并使用“vagrant”作为密码,我得到了这个:

ssh ubuntu@127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:PSnauymZfKi1HIRIKfez5wAnpPFJW9h3eC+TzxiiIWA.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
ubuntu@127.0.0.1's password: 
Permission denied, please try again.
ubuntu@127.0.0.1's password: 

如果我尝试ssh vagrant@127.0.0.1

,我会得到类似的结果
ssh vagrant@127.0.0.1
vagrant@127.0.0.1's password: 
Permission denied, please try again.
vagrant@127.0.0.1's password: 

如果我打开VirtualBox GUI并直接与VM通信,情况也是如此。

我已尝试按照here的说明进行操作,但我猜这是指较旧版本的Vagrant。

我希望我能够在package阶段进行更改,这样当我将自定义Vagrant框分发给其他开发人员时,vagrant ssh才能正常工作,无需按摩任何内容文件事先。

0 个答案:

没有答案