- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script for scp of file to multiple servers using s...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 09:25 AM
тАО04-27-2005 09:25 AM
Solved! Go to Solution.
- Tags:
- scp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 09:37 AM
тАО04-27-2005 09:37 AM
Re: Script for scp of file to multiple servers using ssh.
something like this:
SERVER_LIST="server1 server2 server3"
for server in $SERVER_LIST
do
rcp /local/file $server:/remote/file
done
The problem with this is, you will have to configure
$HOME/.rhosts file in each server and this is
considered, in general, as a bad practice.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 09:38 AM
тАО04-27-2005 09:38 AM
Re: Script for scp of file to multiple servers using ssh.
do
scp -p /roots/bin/XXXX $i:/roots/bin
done
That should do it fairly easily - just change the locations of where your file is and where you want to put it.
Hope this helps
B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 12:37 PM
тАО04-27-2005 12:37 PM
Re: Script for scp of file to multiple servers using ssh.
FILE="/path/myfile"
for NODE in $LIST
do
echo xfer $FILE to $NODE
scp -p $FILE $NODE:$FILE
done
If you wanted to automate the task by using public key auth, use "scp -B -p -i identity_file" syntax instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 01:42 PM
тАО04-27-2005 01:42 PM
Re: Script for scp of file to multiple servers using ssh.
read -r servername
do
scp -p filename $servername:/location
done < serverlist
serverlist is a manually done list of servers.
This assumes you have password free ssh/scp etc set up, working and testing before you begin.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 02:34 PM
тАО04-27-2005 02:34 PM
Re: Script for scp of file to multiple servers using ssh.
for i in ser1 ser2 ser3
do
rcp -p /source $i:/destination
done
To SEP:
how to provide password to server when server ask you password when You use scp to copy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 04:53 PM
тАО04-27-2005 04:53 PM
Solution==server.txt==
server1
server2
#!/bin/ksh
# copy files
# File to be copied
FILE="/tmp/testfile"
LOCATION="/tmp/"
while read server; do
scp -p $FILE $server:$LOCATION
done < server.txt
It will do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2005 05:04 PM
тАО04-27-2005 05:04 PM
Re: Script for scp of file to multiple servers using ssh.
I would go with scp and not with Tienna's solution for rcp. Following is the procedure for setting up passwordless ssh
Passwordless SSH using public/private keys
First server setup
ssh-keygen -t dsa(press enter twice to give a blank password)
cd
cd .ssh
vi .configPress "i" to enter insert mode and copy this into the file:
Host remotehost
User remoteuser
Compression yes
Protocol 2
RSAAuthentication yes
StrictHostKeyChecking no
ForwardAgent yes
ForwardX11 yes
IdentityFile /home/localuser/.ssh/id_remotehost_dsaDo NOT change the last line - it is supposed to say remotehost (not an actual host name). Now,
:wq(save and exit vi)
vi id_dsa.pubIt should look like this:
ssh-dss AAAA..............v root@HOSTNAMEOFSRV01
where there is lots of random letters/numbers where the dots are. Select it all and copy it. Make sure that it is all on one line with no spaces at the start or finish (which will happen if you copy it using putty on windows; test it by pasting it into notepad)
Tip: To copy from putty on windows select the text from within vi and pres Ctrl + Shift. To paste text enter insert mode and press the right mouse button.
Second Server Setup
cd
vi .ssh/authorized_keys
Enter insert mode (press i) and paste the key, again ensuring that there are no spare newlines or spaces. Save the file and exit vi (press :wq then return, as above)
Testing passwordless SSH
On the first server, type
ssh srv02where srv02 = the hostname of the second server. It could be an IP address too.
If it just logs you in (no passwords), then you are done.
Regards,
Naveej
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2005 06:14 AM
тАО04-29-2005 06:14 AM