SSH-PORT-FORWARDING(1)marcp.xyzSSH-PORT-FORWARDING(1)

NAME

ssh-port-forwarding - local forwarding and jump hosts

EXAMPLES

# Example hosts used:
# A: 192.168.1.10 (local machine)
# B: 10.10.10.10 (target server)
# C: 172.16.1.10 (jump host)
# D: 172.16.1.250 (second jump host)

# Local port forwarding: Connect local port 2222 to port 22 on machine B via jump host C
[user@A]$ ssh -L localhost:2222:10.10.10.10:22 user@172.16.1.10

# Use the forwarded connection with X11 forwarding
[user@A]$ ssh -p 2222 -X localhost

# Now X11 programs on B will display on A
[user@B]$ firefox

# Port forwarding through multiple jump hosts (C and D) to reach B
[user@A]$ ssh -L localhost:1236:10.10.10.10:8443 -J user@172.16.1.10,user@172.16.1.250 user@10.10.10.10

SEE ALSO

tor-beacon(1)

marcp.xyz2022-03-22SSH-PORT-FORWARDING(1)