I have a use case where I occasionally want to copy a single file from my host machine to the Vagrant guest.
I don\'t want to do so via traditional provisioners (Pup
An alternative way to do this without installing anything (vagrant-scp etc.) Note that the name default needs to be used as is, since vagrant ssh-config emits that.
vg_scp() {
tmpfile=$(mktemp /tmp/vagrant-ssh-config.XXXX)
vagrant ssh-config > $tmpfile
scp -F $tmpfile "$@"
rm $tmpfile
}
# Copy from local to remote
vg_scp somefile default:/tmp
# Copy from remote to local
vg_scp default:/tmp/somefile ./
# Copy a directory from remote to local
vg_scp -r default:/tmp ./tmp
The function would not be necessary if scp -F =(vagrant ssh-config) ... would have worked across shells. But since this is not supported by Bash, we have to resort to this workaround.