Any way to make scp more powerful?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Any way to make scp more powerful?
# 1  
Old 03-25-2008
Any way to make scp more powerful?

Hello,

I'm writing a script to automate the delivery of our code to different target environments and I was wondering if there's any way to cut down on the number of authentications that are needed. The script has to deliver to three different boxes (two directories on two boxes and one directory on the other) so it would be nice to only have to authenticate three times, one for each box. However, with the two separate directories on two of the boxes, I can't find a way to incorporate the different files from multiple local directories and the multiple remote directories into one command. Therefore, I have to single out each remote directory into multiple transactions, each of which requires a re-authentication.

I've managed to combine multiple files from different local directories to a single remote directory into one command but can't find a way to do it with multiple destination directories. I know it would just be easier to use sftp but the servers we're delivering to don't support ftp.

So, is there any way to do this while keeping the script interactive (i.e. not hard coding passwords into the script)? Any suggestions would be greatly appreciated.

Thanks.
# 2  
Old 03-25-2008
Any reason you don't use public-key authentication? Then you just have to ssh-add the key once and then you won't be asked for passwords after that (or you could even create a passwordless key, if your guts and local policy allow).
# 3  
Old 03-25-2008
One of the servers does use PK authentication but it still requires a passphrase to unlock the private key. The other two are strictly password-based and, unfortunately, the policy is not under our control.
# 4  
Old 03-25-2008
Do they support ssh? If so then sftp is already built in. Sftp is part of ssh. No need for extra configuration, credentials, etc. If you can ssh to a box, you can sftp to a box with same credentials. What kind of boxes are they?
# 5  
Old 03-25-2008
They do support SSH but the FTP doesn't support interaction. When I tried to write a batch file and call it with
Code:
sftp -B batchfile

it says:
Quote:
FATAL: ssh client failed to authenticate. (or you have too old ssh installed, check with ssh -v)
In other words, I didn't want to hard-code the password into the script so I basically had:
Code:
open user@hostname
put file /path/to/remote/dest
put file2 /path/to/remote/dest
quit

in the batch file and it failed executing the first command. I also tried using expect to "watch" my session and that didn't work either. Unfortunately, scp seems like the only thing that is script-able.
# 6  
Old 03-25-2008
Generate your PK file with an empty passphrase. This will serve for your automation requirement..although it also has the dubious "keys to the kingdom" distinction.
# 7  
Old 03-26-2008
rdist utility could match your requirements.
Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

Boy, is the shell powerful.

Reading replies to questions, as an amateur, I have learnt a lot from you pros on here. The shell in any of its guises is serioulsy poweful. With so many transient and resident commands at one's disposal is there anything, non-GUI, that cannot be done inside a default shell and terminal? ... (12 Replies)
Discussion started by: wisecracker
12 Replies

2. Shell Programming and Scripting

An curious idea, how to make it by the powerful script?

I use a simple script to do some quantum calculations with gaussian package. the script as follows #!/bin/sh #put a gaussian input file into a new folder in the same name #and submit this new job for i in *.gjf do FN=$( echo $i | sed 's/.gjf//') mkdir $FN mv... (1 Reply)
Discussion started by: liuzhencc
1 Replies

3. OS X (Apple)

Is Mac OS X Server Really Powerful?

Look We all know that Linux is almost BulletProof and about 40% faster than Win2K3 Server, When running Oracle DB, Right? Now my Question is can OS X run just as Well as Linux as a Server being PowerPC and Whatever, Can it be just as stable? Now You Tell me, Which is most Practical: Linux... (3 Replies)
Discussion started by: RedVenim
3 Replies
Login or Register to Ask a Question