My goal is to access a Ubuntu Server that is running in a local VirtualBox publicly via the internet (both SSH on port 22 and HTTP on port 80).
For now, I planned to do it like this:
- I set up the local VirtualBox (called "A" in the following) normally and start an OpenSSH server on it on port 22 and also a HTTP server that serves some content on port 80.
- At a cloud provider like AWS, I set up another virtual machine instance ("B" in the following) which of course gets a public IP address (e.g. "12.34.56.78", so that B is publicly accessible over SSH at "12.34.56.78:22").
- I now want to establish a persistent SSH-based connection (tunnel?) between A and B, which is where I am currently stuck. Creating this tunnel should be initiated by A.
- When I then connect over SSH to e.g. "12.34.56.78:2222", port 2222 of B should be forwarded to port 22 of A via the tunnel established in step 3, so that I can access my VirtualBox A from anywhere via the regular internet. Similarly, when accessing "http://12.34.56.78", HTTP content should be served from the server running on port 80 of A.
How can I achieve step 3, i.e. establish this tunnel?