Use Fabric to upload your public key to the server
Fabric is a good deployment helper
The following code implements the ssh-copy-id function
Batch upload your id_rsa.pub to a group of servers
@ Task
Def copy_id (file = "~ /. Ssh/id_rsa.pub "):
"Fab push Public Key ssh-copy-id """
Put (file, "/tmp/id. pub ")
Try:
Run ("if [! -D ~ /. Ssh]; then mkdir-p ~ /. Ssh; fi ")
Run ("if [! -F ~ /. Ssh/authorized_keys]; then cp/tmp/id. pub ~ /. Ssh/authorized_keys & chmod 0600 ~ /. Ssh/authorized_keys; fi ")
Run ("cat ~ /. Ssh/authorized_keys/tmp/id. pub | sort-u>/tmp/uniq. authorized_keys ")
Run ("if ['cat ~ /. Ssh/authorized_keys | wc-l '-lt 'cat/tmp/uniq. authorized_keys | wc-l']; then cat/tmp/id. pub >> ~ /. Ssh/authorized_keys; fi ")
Finally:
Run ("rm-f/tmp/id. pub/tmp/uniq. authorized_keys ")
Use Vagrant and Fabric for Integration Testing
Fabric: Python Remote Deployment Tool
This article permanently updates the link address: