LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 02-27-2012, 09:36 AM   #1
sampadray81
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Rep: Reputation: Disabled
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
 
Old 02-27-2012, 09:41 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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.
 
Old 02-27-2012, 09:54 AM   #3
sampadray81
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-27-2012, 10:01 AM   #4
sampadray81
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-27-2012, 11:12 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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
 
Old 02-27-2012, 12:31 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Ahh, I misread your question a fair bit. My bad.

Yeah, puppet all the way! or Func. they would be MY weapons of choice.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i transfer file from multiple pc to server without password using pulic key? tsbandagar Linux - Software 1 01-23-2012 04:09 AM
pfx certification file to extract the RSA private/public key fantasy1215 Linux - Newbie 2 11-15-2011 02:51 AM
Multiple NICs - public and private stormblast Debian 5 04-25-2007 05:02 AM
IPTables - Multiple Public IP's to private IP's matneyc Linux - Security 8 05-27-2005 12:23 PM
Multiple NIC cards - public and private IPs harryinjapan Linux - Networking 2 12-02-2001 04:25 AM


All times are GMT -5. The time now is 08:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration