Update: I have yet to find an actual resolution to my question. I, however, in my reading over the weekend, found a workaround. Ultimately, I believe the issue to be related to the lack of insecure keys associated with the .ssh/authorized keys. In my attempts to add the insecure key to the build, all have failed. So I kept finding references to blocking Vagrant from updating the SSH keys at load. So what I figured was I would try that. I inserted
config.vm.insert_key = false
Which prevented Vagrant from overriding the insecure key. This allowed me to package the environment as a new box as I needed it. I am calling this a workaround as I'll be using the new image on a daily basis, which I do not the insecure key, and will prefer vagrant to override it with my local key. so if at some point I want to make an image of this configured environment, I will need to set everything in my vagrant file, rebuild the image, and again block the insert_key. Which some added steps, but I would rather just be able to update the environment and package it. I'll update the post in the future if I ever find a different resolution.
Original: I have a Vagrantfile that has created a VirtualBox image. I have provisioned the image for my particular use case. Now the time it takes for the provisioning is significant, so I don't want to have to do this every time I bring up a NEW VM, with the same requirements. So I want to create a new base image of this current image.
My original base image was also a custom base image, not pulled from the vagrant cloud. At the time there wasn't a base image of the ubuntu server I wanted to use. So I created a VM, using VirtualBox with an ISO, and used that as the base image I am now using.
So I've provisioned the image how I want it and have attempted to create a base image of it, which seems to have worked. However, what I'm now getting is an error with SSH, as I'm seeing "Warning: Authentication failure. Retrying..." repeated over and over again. Now I can ssh into the device after, but I want to be able to provision these new images in different ways, and that requires it to SSH onto the image during vagrant up. My original base image, my Vagrantfile is very simple, and in all cases, my original image has no issues with creating a new VM and accessing it correctly during Vagrant up.
Here is how I've created the new image.
- Launch original, completely provisioned image
- change to root user
- $apt clean
- reinstall the vagrant insecure key
- $rm -Rf /home/vagrant/.ssh
- $mkdir /home/vagrant/.ssh
- $wget -O /home/vagrant/.ssh/authorized_keys
- chown -R vagrant:vagrant /home/vagrant/.ssh
- chmod 0700 /home/vagrant/.ssh
- chmod 0600 /home/vagrant/.ssh/authorized_keys
- shutdown vagrant image
The vagrant user is still activated, with the original vagrant password, no changes there. but I have attempted to re-add the user and password and I still get the same issue.
Next after finishing the above I move on to the actual box packaging
- $vagrant package --output boxname.box
- $vagrant box add boxname.box --name boxname
and at this point, there aren't any errors or warnings, but when I attempt to bring up a VM for the first time using the new box I get the error.
It appears to be an ssh issue more than likely related to the insecure key, but I thought it was addressed when I added the vagrant insecure key back in. I also made sure that my ssh-agent is active. and looked at the output of ssh-add -L, which I have pointed to my ~/.ssh/id_ed25519 private key.
I've found at one point there was an issue with Vagrant and ed25519, but if it works with my original custom box, why wouldn't it work with this new one? in any case, I also added an RSA key but didn't do anything different.
both images end up using Adapter 1: nat and Adapter 2: hostonly. So there are no differences in the network configuration.
Any suggestions?
Reset to default