4

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!

StephenKing
  • 36,187
  • 11
  • 83
  • 112

1 Answers1

6

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

vagrant box add <box> http://user:pass@devops.example.com/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

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • Thank you for helping. Let me try the concept, as I am using the Vagrant file that maps the JSON file instruction, where I have `"url": "http://devops.example.com/vagrant.box"`. I will let you know If it works or not. – Vadim Zolotokrylin Nov 06 '15 at 03:44
  • Doesn't seem to work anymore: `An invalid option was specified.` – static_rtti Sep 27 '16 at 09:46
  • @static_rtti did you try both option ? – Frederic Henri Sep 27 '16 at 09:50
  • Oh, I just saw your second option, it works. I think you should remove the first one. – static_rtti Sep 27 '16 at 09:51
  • @static_rtti yep it was working still in some older version of vagrant, not sure exactly when they stop supporting it – Frederic Henri Sep 27 '16 at 09:53
  • The http://user:pass@hostname/boxname.box approach works with Vagrant 1.8.6. Though, special characters that are not compliant with with vagrants rfc3986_parser.rb. result in a not recognized download URI. In my case a password containing the / characater breaks functionality. Not sure if this is a bug or wanted behavior. – Metin Nov 01 '16 at 21:14