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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0