Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/9c52f8f05cd21207155b to your computer and use it in GitHub Desktop.
Save ThomasG77/9c52f8f05cd21207155b to your computer and use it in GitHub Desktop.
Minimum fabfile.py to connect to Vagrant
from fabric.api import env, sudo, local, run
def vagrant():
# change from the default user to 'vagrant'
env.user = 'vagrant'
# Get config from vagrant ssh-config output
result = dict(line.split() for line in local('vagrant ssh-config', capture=True).splitlines())
# connect to the port-forwarded ssh
env.hosts = ['%s:%s' % (result['HostName'], result['Port'])]
# use vagrant ssh key
env.key_filename = result['IdentityFile']
def uname():
run('uname -a')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment