Skip to content

Instantly share code, notes, and snippets.

@xahare
Last active May 15, 2020 19:52
Show Gist options
  • Save xahare/1db2970b7b684c0d54c0c15cc32afb98 to your computer and use it in GitHub Desktop.
Save xahare/1db2970b7b684c0d54c0c15cc32afb98 to your computer and use it in GitHub Desktop.
remote vagrant
#!/bin/bash
# this is 3 lines of code. i concider it trivial and not worthy of a licence.
# if you need a license for this, you may concider it public domain.
folder=`basename $PWD`
rsync -av --delete --exclude .git* --exclude-from .gitignore . $VAGRANTHOST:vagrant/$folder
ssh -t $VAGRANTHOST "cd vagrant/$folder && vagrant $*"

rvagrant

Convinience script to run vagrant remotely. This means you can do all your work on your local terminal, only contacting your vagrant host when needed. All vagrant commands should be supported.

requirements

You'll need $VAGRANTHOST set in your environment and a .gitignore, which you probably have anyway.

You'll also need ssh and rsync on both your terminal and the vagranthost. Users running windows locally should be able to use WSL.

The script puts all your vagrant folders in ~/vagrant on the remote host, so make sure there are no name conflicts. or, at least make sure you 'vagrant destroy -f' before using other vagrant folders that share a name.

virt-manager

If your remote host uses libvirt, you may want to use virt-manager, especially if your running a desktop os. Run virt-manager locally, not over ssh+X11. Go to File/Add connection to add your vagrant host.

Browsers

If you need a browser, the easiest way is to

ssh -D NNNN vagranthost

And that as a socks proxy for your browser.

If your running a compartmentalized desktop such as qubes-os, you can make a browser user on the vagranthost, and a dedicated browser compartment with an ssh command key. Its ~/.ssh/config would have these lines in it

Host vagranthost
  User browser
  DynamicForward 1080

on the vagranthost, your browser users ~/.ssh/authorized_keys would look something like this,

command="read" ssh-ed25519 AAAAFAKEFOXNEWS1...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment