Remote programming with SSH and X11 Forwarding

Raspberry PI specific forum
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Remote programming with SSH and X11 Forwarding

Post by mk-soft »

Remote programming with SSH and X11 Forwarding

Sometimes the screen is not connected or too small to programming with Purebasic on the Raspberry
For this, the SSH server on the Raspberry must be activated.

Under Linux it is easy, because X11 is available. Under Windows and macOS, an X11 server must be installed first.

Login Linux:
Start Terminal
- $ ssh -Y pi@<IP or hostname>

Login macOS
Start Terminal
- $ ssh -X pi@<IP or hostname>

Login Window:
Start Xming Server
Start Putty
- Session:
* Hostname 'pi@raspberrypi'
- Connection -> SSH -> X11:
* Enable X11 forwarding
* X display location 'localhost:0'

After logging in to the Raspberry, you can start the X11 application via Terminal.

Example 1:
- $ geany &

Example 2:
- change path to ./purebasic/compilers
- $ ./purebasic &


Downloads Window:
Link Xming: https://sourceforge.net/projects/xming/ ... /6.9.0.31/
Link Xming fonts: https://sourceforge.net/projects/xming/ ... /7.7.0.10/
Link Putty: https://www.chiark.greenend.org.uk/~sgt ... atest.html

Downloads macOS
Link XQuartz: https://www.xquartz.org
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Remote programming with SSH and X11 Forwarding

Post by idle »

Thanks, that will be useful
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Remote programming with SSH and X11 Forwarding

Post by Joris »

@mk-soft thanks.
But...
On Raspbian VNC is pre-installed and easy to activate and use in combo the with VNC-viewer on the different OS's.
Also VNC gives you the active desktop of the Pi, so already active programs opened on the Pi can be remotely handled.
This I could not do with the setup using SSH and X11, a second desktop (new) is openend then.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Remote programming with SSH and X11 Forwarding

Post by dige »

Thanks mk-soft, that helps me with my laptop and Purebasic on Debian 11. On the Raspberry, I prefer also the preinstalled VNC
"Daddy, I'll run faster, then it is not so far..."
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Remote programming with SSH and X11 Forwarding

Post by infratec »

In general:

VNC 'hijack' a device.
XServer and Client allows to start a total different connection with different screen resolution.
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Remote programming with SSH and X11 Forwarding

Post by dige »

@infratec: good point!

I wanted to try this out, but I'm already failing with the ssh activation on the PI.

Which IP do I have to enter? The IP of the computer from which I want to connect the PI, right?
"Daddy, I'll run faster, then it is not so far..."
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Remote programming with SSH and X11 Forwarding

Post by mk-soft »

To connect with ssh The IP address or hostname of the raspberry.

If the SSH server on the raspberry is not yet active:
sudo raspi-config
- 3 Interface Options
- I2 SSH Enable / disenable ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Remote programming with SSH and X11 Forwarding

Post by dige »

Thanks, it works great now. It also works much better than with VNC! Thank you very much!
"Daddy, I'll run faster, then it is not so far..."
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Remote programming with SSH and X11 Forwarding

Post by mk-soft »

Of course, not all the functions of the graphics output are available as directly on the raspberry. (OpenGL, etc).
The programme runs on the Raspberry and the GUI runs on the X11 server of the local machine.
Thus, the output of the GUI also looks different, depending on which X11 server is used.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Remote programming with SSH and X11 Forwarding

Post by Joris »

With SSH and X11, how do you prevent having already openend and running software on the Pi ?
As that setup creates a new desktop on which nothing is shown of running software.
What if making several new connections (after having closed the one before) and not closing active programs on the Pi ?

Ok, you can doe a reboot of the Pi, but that is not a nice way ...
As told VNC show the current active desktop, with SSH always a new clean one.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Remote programming with SSH and X11 Forwarding

Post by mk-soft »

An ssh connection does not have a desktop. The started application runs the GUI output on the local computer in the X11 server. This means on the desktop of the local computer and not on the Raspberry.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Remote programming with SSH and X11 Forwarding

Post by NicTheQuick »

In the past I also had good experiences with XRDP to a normal Ubuntu VM. It can be used on Windows with the default Windows Remote Desktop application.

Of course you can also use it with a Raspberry. Here is just one of many links to that topic: https://linuxize.com/post/how-to-instal ... pberry-pi/

Usually you can change the desktop resolution and other things.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply