Copy files from/to a Vagrant VM with sudo and necessary SSH config
$ vagrant plugin install vagrant-sudo-rsync
# General
## This is equivalent to $ rsync --rsh=<automatically determined> --rsync-path='sudo rsync' [OPTION] SRC DEST
$ vagrant sudo-rsync [OPTION] SRC [DEST]
## Synchronizing from local to remote
$ vagrant sudo-rsync [OPTION] <some_local_file_or_dir> :<somewhere_on_the_vm>
## Synchronizing from remote to local
$ vagrant sudo-rsync [OPTION] :<somewhere_on_the_vm> <some_local_file_or_dir>
# Real life example
## Listing all files under /etc/nginx/ssl on remote
$ vagrant sudo-rsync :/etc/nginx/ssl/
drwx------ 4,096 2017/09/12 00:32:17 .
-rw-r--r-- 424 2017/09/12 00:30:48 dhparams.pem
-rw-r--r-- 1,054 2017/09/12 00:32:17 www.example.cert
-rw-r--r-- 1,708 2017/09/12 00:32:17 www.example.key
## Pulling /etc/nginx/ssl from remote to local desktop
$ vagrant sudo-rsync -av --delete --info=NAME :/etc/nginx/ssl ~/Desktop
receiving incremental file list
ssl/
ssl/dhparams.pem
ssl/www.example.com.cert
ssl/www.example.com.key
sent 85 bytes received 3,469 bytes 7,108.00 bytes/sec
total size is 3,186 speedup is 0.90
- Prefix remote paths with colon (
:
) --rsh
(or-e
) is automatically determined by$ vagrant ssh-config
automatically--rsync-path
is set tosudo rsync
- Anything after
$ vagrant sudo-rsync
is passed to$ rsync
- Never specific
--rsh
,-e
or--rsync-path
- Articles on Typist Tech's blog
- Tang Rufus' WordPress plugins on wp.org
- More projects on Typist Tech's GitHub profile
- Stay tuned on Typist Tech's newsletter
- Follow Tang Rufus' Twitter account
Thanks! Glad you like it. It's important to let mw know this project is useful to somebody. Please consider:
- tweet something good with mentioning @TypistTech and @TangRufus
- ⭐ this Github repo
- watch this Github repo
- write blog posts
- submit pull requests
- donate
- hire me
Love Vagrant Sudo Rsync? Help me maintain it, a donation here can help with it.
Ready to take freelance WordPress jobs. Contact me via the contact form here or, via email [email protected]
Contact: Tang Rufus
Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Vagrant Sudo Rsync is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.
Full list of contributors can be found here.
Please see CODE_OF_CONDUCT for details.
Vagrant Sudo Rsync is released under the MIT License.