Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-27-2012, 10:36 AM
|
#1
|
LQ Newbie
Registered: Feb 2012
Posts: 3
Rep:
|
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
|
|
|
02-27-2012, 10:41 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
02-27-2012, 10:54 AM
|
#3
|
LQ Newbie
Registered: Feb 2012
Posts: 3
Original Poster
Rep:
|
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.
|
|
|
02-27-2012, 11:01 AM
|
#4
|
LQ Newbie
Registered: Feb 2012
Posts: 3
Original Poster
Rep:
|
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.
|
|
|
02-27-2012, 12:12 PM
|
#5
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Quote:
but want to have a command to do it.
|
Well ... you got it, you just posted it.
Code:
while read server
do
scp -p $SOURCEFILE ${server}:$TARGETDIR
done < $HOSTFILE[
Put all that on one line.
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
|
|
|
02-27-2012, 01:31 PM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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 11:20 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|