Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to basically pipe a wget command to a file on a remote server over SSH. How can I do this? I know I could simply ssh into the server and have it download the file, but I'd much rather use the local machine to download it and send it.

share|improve this question

1 Answer 1

up vote 19 down vote accepted

So you are logged into a machine myclient and have ssh access to another machine myserver. You want to download a file over HTTP from a remove server www.example.com to myclient but the data needs to be saved on myserver. This should do it:

wget -O - http://www.example.com/whatever | ssh myserver 'cat >/path/to/remote/destination'

Alternatively, you could mount the myserver's filesystem over SSH with sshfs. This may be too much hassle for a one-off need, but convenient if you do this sort of thing often.

mkdir ~/myserver
sshfs myserver:/ ~/myserver
wget -O ~/myserver/path/to/remote/destination http://www.example.com/whatever
share|improve this answer
    
Yeah, that's exactly what I wanted to do. I needed to run the actual HTTP download on A, but copy the file over SSH to B without actually storing the file on A. Win! –  Naftuli Tzvi Kay Mar 10 '11 at 20:30

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.