LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-28-2015, 02:08 PM   #1
elalexluna83
Member
 
Registered: Mar 2012
Posts: 53

Rep: Reputation: Disabled
SSH execute remote command as local!


Hello Guys,

I need to download huge fixes from a remote server that only accepts https request to my server!

The bad news is that my server is not able to download files directly (using links2/curl/wget) because the policy is to keep as minimal as possible the software installed there.

I'm able to download the fixes to my machine using links2/wget/curl (upload the files from my machine will take days)

Is there a way to from my server connect to my laptop (using ssh) and then execute curl/wget and download the file directly to the server??
 
Old 05-29-2015, 12:46 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,681

Rep: Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857Reputation: 2857
I'm a bit confused, can you please explain it like: host1 OS, host2 OS, which one is your server and which one is your laptop or machine, where do you want to initiate the download and where should it be executed? (otherwise yes, that should be possible)
 
Old 05-29-2015, 03:53 AM   #3
PastulioLive
Member
 
Registered: Nov 2014
Posts: 39

Rep: Reputation: Disabled
I suppose you would have to write a script for this.
I think a good way of doing this would be to pipe the output of wget to SSH on your laptop:

Code:
wget -q0 - <http-download-url> | ssh <user>@<server-machine> cat - > /path/to/file/<filename.ext>
I tested it with the google index page and the command looks like this:

Code:
wget -qO - google.be | ssh pascal@testserver cat - > /home/pascal/google.html
The flags used with wget are
-q for quiet
-O for Output

The dash tells the shell what needs to be piped

You can probably create an array with all the files you need and create a FOR loop to download them all.

EDIT: If you need a more lightweight way of doing this, try looking at netcat. (If it is installed, or allowed to be installed on your server)

Pascal

Last edited by PastulioLive; 05-29-2015 at 03:57 AM.
 
Old 05-29-2015, 05:33 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,707

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
Or maybe use sshfs to mount the remote directory to download into...
 
Old 05-29-2015, 11:31 AM   #5
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 268

Rep: Reputation: 41
Use SSH tunneling.
Code:
laptop # ssh -R 443:repositoryserver:443 root@remoteserver
If laptop is windows based, PuTTy also have similar feature.
Remoteserver's /etc/ssh/sshd_conf could disallow port forwarding, you have to check.

Then, on remoteserver, try updates from https://localhost:443.
Of course, certificate will be broken.
 
Old 05-29-2015, 07:41 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 17,000

Rep: Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513Reputation: 2513
If it is just a file then download it to a system and use usb or other means to transfer.
 
Old 05-30-2015, 02:11 PM   #7
PastulioLive
Member
 
Registered: Nov 2014
Posts: 39

Rep: Reputation: Disabled
Quote:
Originally Posted by voleg View Post
Use SSH tunneling.
Code:
laptop # ssh -R 443:repositoryserver:443 root@remoteserver
If laptop is windows based, PuTTy also have similar feature.
Remoteserver's /etc/ssh/sshd_conf could disallow port forwarding, you have to check.

Then, on remoteserver, try updates from https://localhost:443.
Of course, certificate will be broken.
Wouldn't you still need a http client on the server to download something through the tunnel?
 
Old 05-31-2015, 02:54 AM   #8
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 268

Rep: Reputation: 41
Arghhh. You right. I thought you have problems with firewalling (very common problem),
but you have problem with disallowed web clients.
BTW, do you know that "yum" and "rpm" commands know work over HTTPS directly ?
 
Old 06-05-2015, 07:59 PM   #9
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
Just adding to the options, use scp over ssh to transfer the files. WinSCP considering it is a windows laptop.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh to a remote machine, execute a command | from Cron wh33t Linux - Newbie 2 09-03-2014 05:06 PM
[SOLVED] SSH remote command: Pipe remote output to local machine? kenneho Linux - Server 6 12-06-2012 01:37 AM
Help with Ubuntu server remote ssh and local network ssh issues using putty. scottpops Linux - Server 8 05-17-2012 05:07 PM
shell can't execute through ssh but local well wanghao Programming 1 01-10-2010 11:11 PM
execute multiple ssh remote commands tom221 Linux - Newbie 2 01-28-2005 01:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration