Created
February 20, 2014 20:10
-
-
Save Ceasar/9122195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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