how to transfer multiple file to multiple server using public and private key
Hi,
I have 10 100 MB files in a single server. I want to copy those files into 20 different servers at a single go. Do we have any commands to do the same. Or do we have to follow a particular process to do the same like defining a public and private key. If so how do we do that. Any suggestions would be highly appreciated. Regards, Sampad Ray |
copying files and public keys have nothing in common. If you have ssh working with keys, then you can use scp / sftp to copy fiels between those systems, sure, but it's nonsense to say you're copying them with a key.
|
Actually i had a interview question asking what would you do if you want to copy multiple files residing in a server to multiple servers at once rather than by doing it one at a time.
|
i found this code in the forum:
#/usr/bin/sh # This is a script to copy files from one host to a group of hosts # There are three variables accepted via commandline # $1 = first parameter (/source_path/source_filename) # $2 = second parameter (/target_directory/) # $3 = third paramter (file that contains list of hosts) SOURCEFILE=$1 TARGETDIR=$2 HOSTFILE=$3 if [ -f $SOURCEFILE ] then printf "File found, preparing to transfer\n" while read server do scp -p $SOURCEFILE ${server}:$TARGETDIR done < $HOSTFILE else printf "File \"$SOURCEFILE\" not found\n" exit 0 fi exit 0 but want to have a command to do it. |
Quote:
Code:
while read server If you don't want a "host file" you could change it to a for loop. Code:
for server in server1 server2 server3 ...; do scp -p file ${server}:/path/to/target; done Of course your interviewers might have been after a response like: "I'd use cfengine", or "Puppet, of course", or, "Depending on the existing snmp infrastructure I'd utilise ... " So many options ... Cheers, Tink |
Ahh, I misread your question a fair bit. My bad.
Yeah, puppet all the way! or Func. they would be MY weapons of choice. |
All times are GMT -5. The time now is 07:20 AM. |