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 need to copy a .war file, which i currently just can reach over the UI with "http://server:host/directory/my_file.war". So its not stored on a fileserver. Im logged on a server A and the file needs to be saved on server B.

Is it in general possible to download files from a server A, that are not stored on a fileserver with the scp command to a server B?

Thanks in advance.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

No, scp does not support http:. First copy the file to your computer using curl or wget (or save it with your browser), and then use scp to copy from a local filesystem.

If you have shell access on server B, just ssh to server B, and run wget there to pull the file down directly. This is better in that it only uses bandwidth on serverB and the webserver (in case that matters to you) -- see below for an alternative solution that uses much more bandwidth.

Or, if for some reason you can't download the file directly to server B, do something like:

serverA$ wget --output-document=- http://server:host/directory/my_file.war | \
    ssh user@serverB "cat > /path/to/my_file.war"

This tells wget to fetch the URL to stdout, and then ssh will send that data to serverB and redirect it to a file. Unfortunately, scp can't read a from stdin, so you will need shell access on serverB in order for this to work. Note that if you do this, you'll use 2x bandwidth on serverA (to pull the file from the webserver, and then push it to server B), and you'll use 1x bandwidth on the webserver and serverB.

share|improve this answer
    
with wget its possible to save the file directly to the target server. but is there a security risk compared to scp? –  user1338413 Dec 21 '12 at 13:14
    
Your question doesn't make sense. What do you mean by "target server" -- the machine where you're running the wget command? If you are downloading via http (and not https), then the security risks are inherent in the http protocol and there's nothing scp could do to change that. –  bstpierre Dec 21 '12 at 13:52
    
thanks for the advice, i edited the question a bit. With "target server" i mean the "server B", where i want to copy the file. First i have to connect with the server B with ssh. then i want to download the file. And according to your answer i have to use "wget" to download it first on the server A (where im logged in), and then copy it with scp to server B. So there is no one-step-solution. right? –  user1338413 Dec 21 '12 at 14:07
    
Do you have a shell on server B? Or just scp and no shell access on server B? –  bstpierre Dec 21 '12 at 14:18
    
I think i do have shell access.. why? Sorry, im really new in this. –  user1338413 Dec 21 '12 at 14:53

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.