I'm running Vagrant 2.2.3 on VirtualBox 5.2.26 and have built a Debian box from the "debian/stretch64" image. I built the VM, created a personal account, and then copied my SSH public key to my ~/.ssh/known_hosts file on the VM so I wouldn't need to login with a password. Everything worked fine until I tried to work on the VM while I was on an airplane and disconnected from the Internet. Under this situation, I found it very difficult to connect to the box. I would either get this error:
packet_write_wait: Connection to 192.168.2.107 port 22: Broken pipe
or this one:
Permission denied (publickey)
Are soon as I reconnected to the Internet when I got home, these errors disappeared. Is there some trick to working on a Vagrant VM when your local machine isn't connected to the Internet? I have the virtual machine's IP address in my /etc/hosts file.
2 thoughts on “How to use Vagrant VM when disconnected from Internet?”
\`[192.168.2.107](https://192.168.2.107)\` is local IP address, probably your network manager assigned different IP address to your network interfaces been outside of WiFi connection.
I would blame network manager.
The 192.168.2.107 is probably an address given by your router, and if you’re not at home there is no
192.168.2.\* net (or a different one).
If you don’t need to reach the VM from outside of your laptop, you can use a [private network](https://www.vagrantup.com/docs/networking/private_network.html) instead.