How to use Vagrant VM when disconnected from Internet?

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.

Thanks.

2 thoughts on “How to use Vagrant VM when disconnected from Internet?”

Leave a Comment