Skip to content

Instantly share code, notes, and snippets.

@nathandaly
Forked from mykter/vagrant-scp
Last active May 31, 2018 10:23
Show Gist options
  • Save nathandaly/275ea9161a3b95fbca347cd17fb53cf9 to your computer and use it in GitHub Desktop.
Save nathandaly/275ea9161a3b95fbca347cd17fb53cf9 to your computer and use it in GitHub Desktop.
Copy a file between a Vagrant VM and the host with scp
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | awk -v ORS=' ' 'NF{print "-o " $1 "=" $2}'`
# To copy a file from a Vagrant VM to the host:
# scp -rp ${OPTIONS} v:/srv /srv
# To copy a file from the host to a Vagrant VM:
#scp ${OPTIONS} $FILE v:$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment