I want to copy my authorized keys file to all of my linux hosts at the same time so that I can update it in one location and then push it out to all the others. However, since I'm new to shell scripts I have a couple of questions about this....
I have made a simple test file with:
scp file.txt firstname.lastname@example.org:/root/.ssh
echo "Server has the file now!"
This will prompt me for the root password and then perform the copy as intended. However, if I want to define a variable $SERVERS in this file and then have a list of all the hosts by IP and change the script to use: scp file.txt root@$SERVERS:/root/.ssh....how can I write that?
Also, I need a way to use an admin user account for the servers instead of the root account. For example, I have my own user that uses a private/public key to login as the root, but how can I use that user account to do the SCP to each box? If I use the root user I would have to type in the password for each box because they are different which totally ruins the purpose.
Any help would be appreciated.