Either can run X applications via ssh X tunneling (using ssh -X
or, better, ssh -Y
), and then your local X server will be used to render them, which means they won't appear on the remote desktop, or run them rendered on the Pi's X server which is running on the Pi and is displaying over its HDMI, and attach to the same X server using VNC protocol (under the hood the XTest extension is used to retrieve the picture and to inject keystrokes and mouse events into physical X screen). You can't have both.
However, you can tunnel VNC traffic through SSH and there is wonderful ssvnc
suite (x11vnc
is the part of this suite). This approach could make it appear similar to Microsoft's RDP: you have a dedicated GUI to connect, it SSH'ses into the remote, starts x11rdp, then tunnels VNC over the same connection and starts VNC client locally to connect to that tunneled connection.
Or, you can just have vncviewer
locally and x11vnc
remotely, and do the same thing manually:
# (locally)
ssh pi@remote-rapsberry-pi -L 5900:localhost:5900
# (in this remote shell)
x11vnc
Then, locally, in another terminal
vncviewer localhost
You can use other port on the local machine if you want to; try -L 5906:localhost:5900
and vncviewer localhost:6
. Notice that in VNC terms the thing after the colon is not the port, but screen ID, and the port where server is listening is expected to be 5900 + screen ID.