This is just a quick note for me on pushing SSH keys using
~/hosts.txt file contains a list of remote hosts, one per line. And the
~/.passwd.txt contains your password. Make sure to
chmod 400 ~/.passwd.txt and delete it after you’re done, to maintain some semblance of security. Another option is to
read -s SSHPASS; export SSHPASS and then use
sshpass -e to work with the environment variable. I don’t know if this is more secure, but it’s more of a hassle, so it must be.
And here’s the command. Pretty simple:
xargs -n 1 -P 10 -a ~/hosts.txt -I % sshpass -f ~/.passwd.txt ssh-copy-id '-o ConnectTimeout=5 -o StrictHostKeyChecking=no %' 2>/dev/null
You can adjust the number of parallel threads
-P based on the number of CPU cores you have. Also, when running many parallel threads, you may want to up the
Experienced Unix/Linux System Administrator with 20-year background in Systems Analysis, Problem Resolution and Engineering Application Support in a large distributed Unix and Windows server environment. Strong problem determination skills. Good knowledge of networking, remote diagnostic techniques, firewalls and network security. Extensive experience with engineering application and database servers, high-availability systems, high-performance computing clusters, and process automation.