Connecting to systems beyond the remote host

LocalForwarding can even be used to access hosts that the remote machine can see, but your local one can't.

Consider the following configuration entry:

Host *
IdentityFile ~/.ssh/id_ed25519
Port 22

Host CentOS2-V4
Hostname 192.168.33.11
LocalForward 7777 192.168.33.12:6666
User vagrant

In this example, centos2 can see the host with the IP 192.168.33.12, and the server it's got listening on port 6666.

When we connect to centos2 and create our tunnel, we can connect locally to 127.0.0.1:7777, viewing the web server on 192.168.33.12:6666.

This is widely used in conjunction with bastion hosts, which we will look at soon.