I try to create a vagrant box of my own and I followed the instructions provided by HashiCorp.
After creating the machine, I packaged my box and created a new vagrant test environment (with box add
and init
). Everything as suggested in the article above. I always end up with errors on vagrant up
:
default: Warning: Authentication failure. Retrying...
The box itself boots and I can also ssh into it, only vagrant seems not to be capable. I already tried ssh suggestions as described in this blog. I replaced the public key, with the official one described in the vagrant instructions and hosted on this GitHub repository.
When I ssh from host into the guest machine (fired up by vagrant) and query ssh service status it says:
Connection closed by authenticating user vagrant 10.0.2.2 port 53446 [preauth]
Just in case it matters, my guest/box machine is Debian buster, virtualbox is my provider and I am creating everyhting based on vagrant 2.2.17 and virtualbox 6.1.22 (r144080).
What did I miss? How to fix that?
After some more tests, I finally recognized my mistake. HashiCorps says:
To configure SSH access with the insecure keypair, place the public key into the ~/.ssh/authorized_keys file for the "vagrant" user. Note that OpenSSH is very picky about file permissions. Therefore, make sure that ~/.ssh has 0700 permissions and the authorized keys file has 0600 permissions.
Unfortunately, I did just flipped permissions ending up that vagrant had r+w+x on the keyfile and only r+w on the folder. As it is said, OpenSSH is very picky... Finally I recognized my mistake and now everything works as expected. It would have been a lot easier with a more detailed error message.