Problem:

I need to update the OS and download software, but my linux system (Machine A) do not have internet access. My computer (Machine B) have internet access.

Solution:

I will use a ssh proxy connection to access to internet through machine B.

Steps:

1. Login from machine A to machine B by SSH using the -D option. Example.

ssh-D 8989  -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" [email protected]

8989 is the port I will use to proxy the access.

From man page of ssh:

-D [bind_address:]port
Specifies a local “dynamic” application-level port forwarding.
This works by allocating a socket to listen to port on the local
side, optionally bound to the specified bind_address.

2. From Machine A test if the port 8989 is open.

[usuarioaurlen@servidorA ~]$ telnet localhost 8989
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

4. Keep open the ssh connection to be able to access to internet.

CURL usage.

To use the ssh proxy in curl use the -x option.

Example:

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

yum usage

1. Edit the file /etc/yum.conf and add proxy=socks5h://localhost:8989

proxy=socks5h://localhost:8989
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.lo

2. You can use yum as normal.

yum upgrade
yum install nmap