Virtualbox / Vagrant "closed by remote host" during routine use

Solution 1:

I encountered the same issue, and it was the RAM, was filled by a huge rsync command. Same applys for cp or mv from within a VM. I imagine that it will be the same with a big apt install ... on pip install .... You need more RAM or find workarounds.

You can try to figure it out too by running your script/provision and in another tab, htop from the host. For me, the RAM get filled more and more each seconds until the crash when Out Of Memory (OOM killer) occurs. The ssh error is just a consequence, not the root cause.

A posssible workaround is:

mount --bind host-shared-dir mountpoint

Note

If someone knows why cp/mv/rsync takes so much RAM from host when you rsync from within a VM, please explain ;)