Skip to content

Instantly share code, notes, and snippets.

@ehernandez-xk
Forked from geedew/vagrant-scp
Created April 12, 2017 13:56
Show Gist options
  • Save ehernandez-xk/03a957c820f6f0eab477b048ccd2d8ef to your computer and use it in GitHub Desktop.
Save ehernandez-xk/03a957c820f6f0eab477b048ccd2d8ef to your computer and use it in GitHub Desktop.
Copying files to a Vagrant VM from host
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
SERVER=localhost
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | awk -v ORS=' ' '{print "-o " $1 "=" $2}'`
scp ${OPTIONS} $FILE vagrant@$SERVER:$PATH
@ehernandez-xk
Copy link
Author

This works well for me

OPTIONS=`vagrant ssh-config | grep -v '^Host ' | awk -v ORS=' ' '{print "-o " $1 "=" $2}'`
echo $OPTIONS

-o HostName=127.0.0.1 -o User=docker -o Port=2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o IdentityFile=/Users/ehernandez/.vagrant.d/insecure_private_key -o IdentitiesOnly=yes -o LogLevel=FATAL -o =

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