Skip to content

Instantly share code, notes, and snippets.

@dergachev
Last active June 30, 2021 17:47
Show Gist options
  • Save dergachev/5935044 to your computer and use it in GitHub Desktop.
Save dergachev/5935044 to your computer and use it in GitHub Desktop.
How to copy files into vagrant vm

Vagrant SCP

Do you need to copy a file to your Vagrant VM? Unfortunately there's no vagrant scp command as far as I know. But we can use vagrant ssh in a pinch:

cat ~/.gitconfig | vagrant ssh -- 'tee ~/.gitconfig'

Do you want to move over multiple files?

# copies ~/FILE1.TXT and ~/FILE2.TXT to /tmp/FILE1.txt and /tmp/FILE2.txt
tar cz --directory ~ FILE1.TXT FILE2.TXT | vagrant ssh -- 'cd /tmp; tar xzf -'

Make sure you understand what the --directory option to tar does.

@toddlers
Copy link

vagrant ssh -- -l username

logging to vagrant box using the custom added user

This one I use mostly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment