Skip to content

Instantly share code, notes, and snippets.

@thedoc31
Created February 3, 2017 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedoc31/8f0288957ce11441f7a3803f4e946c5b to your computer and use it in GitHub Desktop.
Save thedoc31/8f0288957ce11441f7a3803f4e946c5b to your computer and use it in GitHub Desktop.
Batch copy SSH key to multiple servers from an input text file
## serverlist should be FQDN or IP addresses, one server per line, no delimiters
## command will fail if serverlist.txt is not in UNIX format
while read name || [[ -n $name ]]; do sshpass -f ~/<yourpassword>.txt ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa.pub $name; done <serverlist.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment