While it is cool to have a virtual machine so easily, not many people want to edit files using just plain terminal-based editors over SSH. Luckily with Vagrant you do not have to. By using synced folders, Vagrant will automatically sync your files to and from the guest machine.
By default, Vagrant shares your project directory (remember, that is the
one with the Vagrantfile) to the
/vagrant directory in your guest machine.
Note that when you
vagrant ssh into your machine, you're in
/home/vagrant is a different directory from the synced
If your terminal displays an error about incompatible guest additions (or no
guest additions), you may need to update your box or choose a different box such
hashicorp/precise64. Some users have also had success with the
vagrant-vbguest plugin, but it
is not officially supported by the Vagrant core team.
Create and configure a guest machine, as specified by your Vagrantfile.
vagrant up # ...
SSH into your virtual machine to see the synched file.
vagrant ssh # ...
On the virtual machine, list the files in the vagrant directory.
vagrant@precise64:~$ ls /vagrant Vagrantfile
Believe it or not, the Vagrantfile that you see inside the virtual machine is actually the same Vagrantfile that is on your actual host machine.
To test this, add a new folder in your virtual machine's vagrant directory.
vagrant@precise64:~$ touch /vagrant/foo
End your SSH session.
List the contents of your local vagrant directory, and notice that the new directory you created on your virtual machine is reflected there.
ls foo Vagrantfile
Whoa! "foo" is now on your host machine. As you can see, Vagrant kept the folders in sync.
With synced folders, you can continue to use your own editor on your host machine and have the files sync into the guest machine.
You have successfully interacted with your host machine via synced folders on the guest machine. Read on to learn about installing packages, users, and more with provisioning.