Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transfering files using scp

Status
Not open for further replies.

ddanj

IS-IT--Management
Jul 19, 2005
9
0
0
US
So I'm trying to write a Perl script to transfer authorized_keys to all the computers on the network from a master computer, but I am having trouble. I'm trying to use scp to copy the whole directory like so:

scp -r ./keys/ $some_machine:/root/.ssh

objective: What I want to accomplish is to have the contents of keys be copied into .ssh, either if .ssh exists or not

the thing is, the first time I run this script, the .ssh directory does not exist on the network machines, so the 'keys' directory gets renamed as .ssh and transfered(from what I understand), which is fine. But if I want to add another computer to the network and use the scrip again, instead of overwriting the .ssh directory with the correct files(on machines that i pushed the file to previously), it 'moves' the whole 'keys' directory to the already existing .ssh directory. So now, the .ssh directory will contain a 'keys' directory, instead of the contents of the 'keys' directory. I have no idea how to get around this, any help would be much appreciated!

-ddanj
 
First, try creating the directory on the remote computers by adding a line to your script like

"ssh host mkdir /root/.ssh"

Then try "scp -r ./keys/* $machine:/root/.ssh/"

 
well the thing is, i have an expect script, that uses scp, sp I dont have to enter the password 50 times or however many computers there are on the network. The whole purpose is to push the authorized_keys through, so THEN I can use other scripts, to just ssh in and do things without a password. So thats why I can't really create the directory on the remote machine seperately like that
 
Won't expect work as well with ssh as with scp? I've used it with telnet and it works just fine.
 
yea i guess, i just didnt want to mess with the expect stuff. to try to keep it Perl only. I just tried rsync -e ssh -r /source host:destination, and that seems to be working. So I'm gona try to modify the already existing scp expect script, and replace the scp with the rsync, and see what happens, i'll report back

thanx all

-ddanj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top