Tunnels
Example 1
Connect to a host that it is not in your network via said host’s gateway
from: local machine (192.168.122.1)
to: 10.10.10.3
via: gateway (192.168.122.77 | 10.10.10.1)
user@local: ssh -L 22003:10.10.10.3:22 user2@192.168.22.77 # connects to gateway
user@local: ssh -p 22003 user2@localhost # connects to 10.10.10.3
Example 2
Connect to PostgreSQL in a host in your network
from: local machine (192.168.1.126)
to: 192.168.1.196
via: local machine (192.168.1.126 | localhost)
user@local: ssh -L 5555:localhost:5432 root@192.168.1.196
Example 3
Connect to a web page at port 8443 in a host in your network
from: local machine (192.168.1.126)
to: 192.168.1.193
via: local machine (192.168.1.126 | localhost)
user@local: ssh -L 8000:localhost:8443 root@192.168.1.193
Going to http://127.0.0.1:8000
will take you to http://192.168.1.193:8443
.
Example 4
Connect to a host that is not in your network via another host that is not in your network either
from: local machine (192.168.1.126)
to: devops1 (82.223.1.1)
via: proxy (82.223.1.2)
user@local: ssh -A -t proxy ssh -A -t devops1
Or:
.ssh/config:
------------
Host proxy
Hostname 82.223.1.1
Host devops1_tun
ProxyCommand ssh -W %h:%p user@proxy