Last active
June 10, 2016 13:52
-
-
Save mtsuszycki/b4b33e02a951baf7988784a2db99c720 to your computer and use it in GitHub Desktop.
execute remote command via ssh passwordlessly (no ssh keys) on many hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute remote command via ssh passwordlessly (no ssh keys) on many hosts | |
export SSHPASS=my_password # sshpass will use it | |
printf "host1\host2\n" | xargs -i sshpass -e ssh your_username@{} 'ls -la' | |
# or | |
cat hostlist.txt | xargs -i sshpass -e ssh your_username@{} 'ls -la' | |
# mass copy ssh public key onto many hosts | |
cat hostlist.txt | xargs sshpass -e ssh-copy-id -i ~/.ssh/id_rsa.pub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment