Lets suppose that you have the following topology:
Work -> Firewall (port forwarding) -> Server -> Target.
If your problem is that you are not getting the X11 on Target
because you are doing ssh -X Server
and then inside Server
you are doing ssh -X Target
this might work for you.
ssh
allows you to forward ports too. You can use a ssh
connection to get a remote port mapped in a local port. For example to access Target
one can:
Map the port 22
on Target
to a local port 20000
using the Server
connection (keep this connection open or use -Nf option).
ssh -L20000:Target:22 Server
Then connect to Target
using this mapped port.
ssh -p 20000 -X localhost
How can you?
I've been using the below method from the (now suspended) Xmodulo site to remote into my entire Raspberry Pi desktop from any Ubuntu machine. Works with my original RPi, RPi2 and RPi3. Of course you have to mod sshd_config to allow X11 forwarding on the remote machine (I'd say client/host, but I believe they are different in X11 from other uses and I may confuse myself). Mind the spaces -- they break this procedure frequently when I can't type.
You then have the entire desktop and can run the machine as if physically connected. I switch to Ubuntu using CTRL+ALT+F7, then back to RPi with CTRL+ALT+F2. YMMV. A quirk: You must physically release CTRL+ALT before hitting another function key when switching back and forth.
Original link: http://xmodulo.com/2013/12/remote-control-raspberry-pi.html
Original work attributed to: Kristophorus Hadiono. The referenced pictures are, sadly, lost.
============== 8< ==============
Method #3: X11 Forwarding for Desktop over SSH
With X11+SSH forwarding, you can actually run the entire desktop of Raspberry Pi remotely, not just standalone GUI applications.
Here I will show how to run the remote RPi desktop in the second virtual terminal (i.e., virtual terminal 8) via X11 forwarding. Your Linux desktop is running by default on the first virtual terminal, which is virtual terminal #7. Follow instructions below to get your RPi desktop to show up in your second virtual terminal.
Open your konsole or terminal, and change to root user.
$ sudo su
Type the command below, which will activate xinit in virtual terminal 8. Note that you will be automatically switched to virtual terminal 8. You can switch back to the original virtual terminal 7 by pressing CTRL+ALT+F7.
# xinit -- :1 &
After switching to virtual terminal 8, execute the following command to launch the RPi desktop remotely. Type pi user password when asked (see picture below).
# DISPLAY=:1 ssh -X pi@192.168.2.5 lxsession
You will bring to your new virtual terminal 8 the remote RPi desktop, as well as a small terminal launched from your active virtual terminal 7 (see picture below).
Remember, do NOT close that terminal. Otherwise, your RPi desktop will close immediately.
You can move between first and second virtual terminals by pressing CTRL+ALT+F7 or CTRL+ALT+F8.
To close your remote RPi desktop over X11+SSH, you can either close a small terminal seen in your active virtual terminal 8 (see picture above), or kill su session running in your virtual terminal 7.
Best Answer
I guess this is not really an answer, but it might be a starting point.
I started a bunch of extra X servers using xinit like so;
It looks like I can even start multiple gnome3 and xfce sessions on different virtual displays
And now I can start stuff in those sessions by exporting the DISPLAY var
export DISPLAY=:3
and then select it using the Ctrl-Alt-F2, F3 etcHowever I have absolutely no idea what I am doing (am I switching DISPLAY, session, console, or tty?), its just pretty cool, as you say... ;-)