Push Your SSH Public keys using Fabric

Published on 2009-04-30 15:45:00+00:00
Python   fabric  

This came across my twitter radar today from @bitprophet (aka: Jeff Forcier), who just happens to be the new maintainer for Fabric:

def push\_key():  
    keyfile = '/tmp/%s.pub' % env.user  
    run('mkdir -p ~/.ssh && chmod 700 ~/.ssh')  
    put('~/.ssh/id\_rsa.pub', keyfile)  
    run('cat %s >> ~/.ssh/authorized\_keys' % keyfile)  
    run('rm %s' % keyfile)  

Everything you need to push your public key to an external server using Fabric.