Vagrant: 401 downloading box using json in box_url

Created on 17 Apr 2017  ยท  5Comments  ยท  Source: hashicorp/vagrant

Vagrant version

1.9.1

Host operating system

Win 7 Pro

Guest operating system

Centos 7

Vagrantfile

config.vm.box_url = "https://user:[email protected]/repository/vagrant/centos.json"

{
"name": "centos6",
"description": "centos6",
"versions": [{
"_comment": "centos6",
"version": "1.1.0",
"providers": [{
"name": "virtualbox",
"url": "https://repo.private.com/repository/vagrant/centos.box",
"checksum_type": "sha1",
"checksum": "865754195939814ce12650beb7ad8480ab882"
}]
}]
}

Debug output

INFO subprocess: Starting process: ["C:\HashiCorp\Vagrant\embedded\bin/curl.EXE", "-q", "--fail", "--location", "--max-redirs", "10", "--user-agent", "Vagrant/1.9.1 (+https://www.vagrantup.com; ruby2.2.5)", "--continue-at", "-", "--location-trusted", "--output", "C:/Users/Rak/.vagrant.d/tmp/box0859c2ac170fe9a512c4c8f2cc573831412d8197", https://repo.private.com/repository/vagrant/centos.json"]

INFO subprocess: Starting process: ["C:\HashiCorp\Vagrant\embedded\bin/curl.EXE", "-q", "--fail", "--location", "--max-redirs", "10", "--user-agent", "Vagrant/1.9.1 (+https://www.vagrantup.com; ruby2.2.5)", "--continue-at", "-", "--location-trusted", "--output", "C:/Users/Rak/agrant.d/tmp/box0859c2ac170fe9a512c4c8f2cc573831412d8197", "https://repo.private.com/repository/vagrant/centos.box"]

The requested URL returned error: 401 Unauthorized
An error occurred while downloading the remote file. The error essage, if any, is reproduced below. Please fix this error and try gain.

The requested URL returned error: 401 Unauthorized
INFO interface: Machine: error-exit ["Vagrant::Errors::DownloaderError", "An error occurred while downloading the remote file. The error\nmessage, if any, is reproduced below. Please fix this error and try\nagain.\n\nThe requested URL returned error: 401 Unauthorized"]

Expected behavior

We have a private server where we store our vagrant boxes and we use json to maintain versions.
"vagrant init centos6 https://repo.private.com/repository/vagrant/centos.json" gives us the vagrantfile with box_url as expected.
We change the url to add credentials like user:[email protected]/repository/vagrant/centos.json
When we do a vagrant up, we get an 401 because vagrant doesnt reuse the credentials for downloading the box. As shown in the log, during the curl for json it passes the credentials correctly where-as when it tries to download the right version/box the credentials are missing

Actual behavior

401 error downloading the box

Steps to reproduce

  1. use json to version ur box
  2. setup private repo to store boxes
  3. do vagrant init and change the box_url in vagrantfile
  4. do vagrant up
core

Most helpful comment

Just in case someone ends up, here is what i have done :

All 5 comments

You might need to add VAGRANT_SERVER_URL on top of your Vagrantfile.

ENV["VAGRANT_SERVER_URL"] = "https://repo.private.com"

If i set the VAGRANT_SERVER_URL variable and

  • then use only config.vm.box_url = "centos.json" it tries to look for a json file in local directory and fails
  • use full url (with credentials) on config.vm.box_url and use only box name in json (which is on server), it downloads the json correctly but when it tries to download the box it fails as it searches for box on local directory rather then using the server

    • use full url (with credentials) on config.vm.box_url and use full url (without credentials) for box in json (which is on server), it downloads the json correctly but when it tries to download the box it fails with 401 as before.

@rakeshm707

can you try:

config.vm.box = "https://user:[email protected]/repository/vagrant/centos.json"

Just in case someone ends up, here is what i have done :

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rrzaripov picture rrzaripov  ยท  3Comments

rhencke picture rhencke  ยท  3Comments

janw-me picture janw-me  ยท  3Comments

jazzfog picture jazzfog  ยท  3Comments

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments