Last active
October 11, 2023 11:26
-
-
Save BSN32/8e90ef61da53a953af347bf26257788b to your computer and use it in GitHub Desktop.
Read IP hosts from ip.txt and execute ssh and scp through them
This file contains hidden or 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
# Read IP hosts from ip.txt and iterate through them | |
# send "executable" file over ssh and do some stuff | |
while IFS= read -r dest; do | |
if scp -P8787 -O -oHostKeyAlgorithms=+ssh-rsa executable "root@$dest:/tmp/."; then | |
echo "Success fw transfer: $dest" | |
fi | |
if ssh -n -oHostKeyAlgorithms=+ssh-rsa "root@$dest" -p22 'mv /tmp/executable /root/executable && chmod +x /root/executable && ls -lah /root/executable'; then | |
echo "Success: $dest" | |
sleep 1 | |
else | |
echo "Failed: $dest" | |
fi | |
done <ip.txt 2> ssherr.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment