Push Your SSH Public keys using 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.