How to keep X when you ssh through two nodes

You need to run an X application from a computer behind a NAT network. You can SSH to the NAT box, and from there you can ssh to the computer. But then you lose X.

A=Mycomputer --> the internet --> nat_box --> C=computer

Solution

Mycomputer# ssh root@natbox
  natbox# ssh   -L 24:localhost:22 -g user@C

# switch to new xterm ortab
mycomputer# ssh -Y -p 24 user@C
C-computer# start you application

note

When you are logged onto the natbox, you probably need to find the IP-address of C. On openwrt check /tmp/dhcp.leases

You to not have to be root on B. But if you are not, you must choose a port number > 1024 instead of 24.

Som programs can be tricky to start on a remote display. Eg. to start OpenOffice, you have to kill all OpenOffice processes on C-computer.