I am trying to copy my profile to a list of servers ( 5K ). I am using a private key to get the authentication working. Everything runs smoothly and as expected but I have this small annoyance :
Sometimes a server does not accept my key ( thats ok, I dont care if a few servers dont receive my profile ) but as the same was rejected, a prompt pops up asking for password and stops the execution until I type CTRL-C to abort it.
How can I make sure SCP uses the key and ONLY the key, and never prompts for any password?
NOTE : Im planning to add an ampersand at the end so all the copies will be done in parallel later.
#!/bin/bash
while read server
do
scp -o "StrictHostKeyChecking no" ./.bash_profile rouser@${server}:/home/rouser/
done <<< "$( cat all_servers.txt )"
-B' Selects batch mode (prevents asking for passwords or passphrases)