Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to scp about a half dozen files in a couple directories to the same directories on a target machine.

Without utilizing ssh keys, is this possible in one call?

For example:

scp /path/to/fileA,/anoth/erpath/to/fileB,/yet/more/files/*    #continue next line
    destination:/path/to,/anoth/erpath/to,/yet/more/files
share|improve this question
add comment

4 Answers

up vote 8 down vote accepted

Zip up the files on the sending side and unzip them on the receiving side.

tar -cf - /path/to/fileA /anoth/erpath/to/fileB /yet/more/files/* |
ssh -C destination 'cd / && tar -xf -'

You could also script an sftp session, or use rsync with the right filter.

share|improve this answer
    
if you only have a few files you have to copy in total than I appreciate the scp -r solution. but for more this is much faster. –  xaedes Oct 19 '13 at 18:40
add comment

You can copy from multiple src to one destination. scp -r src1 src2 ... dst But not to multiple destinations.

One option is to copy all the directory to a temp destination directory. Then move them back afterwards.

share|improve this answer
    
this works as good as the tar-ssh solution. plus it is easier to type/remember. it also gives you feedback what is being uploaded. BUT if you have many little files to copy tar-ssh will be much faster, as it only has to transfer one big file, whereas scp-r copies each file individually with much more overhead. –  xaedes Oct 19 '13 at 18:39
add comment

Look at pssh package. It has parallel-scp command. -h option allows you to provide text file with multiple hosts as destination (one per line).

share|improve this answer
    
does this get around needing to ask for the passwords each time a file from A goes to B? –  warren Sep 30 '10 at 13:39
2  
For that I am using ssh-add. You type your credentials once at the beginning of a day. Then you are logged in automatically. –  Casual Coder Sep 30 '10 at 17:03
    
thanks for the suggestion :) –  warren Oct 1 '10 at 18:35
add comment

I use the following command to copy multiple files to multiple destinations.

scp -r src{1,2,3} dest{1,2,3}

this command acts like the following set of commands

scp -r src1 dest1

scp -r src1 dest2

.

.

.

scp -r src3 dest2

scp -r src3 dest3

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.