Skip to content

Instantly share code, notes, and snippets.

@Ceasar Ceasar/fabfile.py
Created Feb 20, 2014

Embed
What would you like to do?
"""
fab -H [hostname] [command]
"""
from fabric.api import run
HOME = '/Users/ceasarbautista'
def authorize():
"""Authorize access to a remote machine.
Password checks will no longer be required.
Usage: fab -H [hostname] authorize
"""
with open('%s/.ssh/id_rsa.pub' % HOME) as f:
public_key = f.read()
run('echo "%s" >> .ssh/authorized_keys' % (public_key,))
def alias(alias, user, hostname, port=22):
"""Set an alias for remote machine.
Usage: fab alias:alias,user,hostname,port
"""
with open('%s/.ssh/config' % HOME, 'a') as f:
f.write('Host %s' % alias)
f.write('\n HostName %s' % hostname)
f.write('\n Port %s' % port)
f.write('\n User %s' % user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.