Search code examples
vagrantbasic-authenticationvagrantfile

Vagrant can not access the box over HTTP Basic Auth


Vagrant up can access and download my Vagrant box (that I packed and placed on my hosting) by http://devops.example.com/vagrant.box. But I do not want my box to be public, and want to protect is by using HTTP Basic Auth. When I turn on Basic Auth and do 'vagrant up', Vagrant returns message with 401 error.

How can I configure Vagrant, so it can access the box over Basic Auth?

Thanks in advance, Cheers!


Solution

  • For HTTP Basic Authentication, you can do (from Vagrant 1.8)

    vagrant box add <box> http://user:[email protected]/vagrant.box
    

    In some older version of vagrant, the following is working

    vagrant box add <box> http://devops.example.com/vagrant.box -u user:pass
    

    If you distribute your box on vagrantcloud you can enable better authentication, you can review https://atlas.hashicorp.com/help/vagrant/boxes/distributing