How to access my homelab from external environment - toge510/homelab GitHub Wiki

Can access homelab via xserver from the external environment.

  • homelab: 192.168.11.2 (private IP address)
  • xserver: 183.XXX.XX.X (public IP address)
flowchart LR
    external --> xserver --> homelab

To access homelab from the xserver, reverse ssh tunnel needs to be established.

Create reverse ssh tunnel on homelab

Run the following command on homelab

ssh -p 10022 -f -T -N -C -R 2222:localhost:22 <xserver's user>@<xserver's IP address>

Access homelab via xserver from the external environment

Access xserver

ssh -p 10022 <xserver's user>@<xserver's IP address>

Access homelab from xserver

ssh -p 2222 <homelab's user>@localhost

Proxy Jump

In the prvious section, you can run the two command to access homelab from the external environment. It's not good.
You can define the host info in .ssh/config as shown below.

Host xserver
  HostName 183.XXX.XX.X
  Port 10022
  User togesohei
  IdentityFile ~/.ssh/id_rsa

Host homelab
  HostName localhost
  Port 2222
  User goto
  IdentityFile ~/.ssh/id_rsa.xserver
  ProxyJump xserver

You can access homelab from the external env with the following command.

ssh homelab