3

I have a Machine A with no access to internet. I have a Machine B with access to internet.

A & B can connect to each other via ssh.

I'd like to make some program installs on A (perl, R package etc...) from internet repository using the internet connexion of B.

Is this possible & and how i could do that ?

Thanks.

ZheFrench
  • 131
  • 1
  • 4

3 Answers3

4

If A & B are both using OpenSSH, then on one window in host A do:

ssh -D 1080 user@B

to start a SOCKS proxy that listens on A:1080 and sends connections to the requested address through B.

As long as this connection is up, you can then run other programs that support SOCKSv4 or SOCKSv5 proxies (this is different from HTTP proxies) on A:

curl -x socks5h://localhost:1080 http://www.google.com/

You can try setting the http_proxy environment variable to socks5h://localhost:1080 but most programs will probably expect this to be an actual http proxy and not be able to communicate with it.

Another option (possibly easier) is just to download everything onto host B, then use scp or sftp to transfer the files over to A.

DerfK
  • 19,493
  • 2
  • 38
  • 54
  • I can't install stuffs on B. I know the ssh -D 1080 ...i use that to browse app on the network at my work from outside.Bbut when you want to use Yum, or install (R packages dependencies) or make a wget, i don't see how to use it with curl :/ – ZheFrench Oct 10 '14 at 08:17
4

It's possible using SSH tunneling:

On your home server:

ssh -R 9999:<proxy host>:<proxy port> user@remotehost

This will open the port 9999 on your remote server and create a tunel to your proxy.

On the remote server you have to edit yum.conf and add the following:

proxy=http://127.0.0.1:9999

This will connect to the proxy using the tunnel we had setup earlier.

If you don't have any proxy in place, you can use dynamic tunelling. It only works if your network does not have any proxy in place, or if it employs transparent proxy.

On the remote server:

ssh -D 9999 user@ip-of-local-server

This will connect to your local server, open the port 9999, and create a dynamic tunnel. The yum.conf alterations will be the same.

ThoriumBR
  • 5,302
  • 2
  • 24
  • 34
  • On the second technique, what do you mean 'the yum.con alterations will be the same' . I need to change on my home server proxy=http://127.0.0.1:9999? – ZheFrench Oct 10 '14 at 08:17
  • No, you must keep the same file, with the same line `proxy=http://127.0.0.1:9999` added to it. – ThoriumBR Oct 10 '14 at 13:08
2

If system A can't get the offical repos you can setup a local mirror on system B and use this as your install/update repo for all packages.

A detailed howto for CentOS can be found in CentOS Wiki

deagh
  • 2,019
  • 5
  • 19
  • 19