How to open the display from ssh login?

Is there any way to open the desktop display from terminal(ssh login)?


You can use the -X option to forward graphical applications. People typically forward single applications or the taskbar or panel rather then the entire desktop. For applications such as Firefox people typically "tunnel".

ssh -X user@server

Then you can

startkde &

To use Xephyr :

sudo apt-get install xserver-xephyr

Start a Xephyr session

# change "1280x1024" to the size you desire
Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &

Set your $DISPLAY (assuming Xephyr is on :1)

DISPLAY=:1.0

ssh in to your server and start kde

ssh -XfC -c blowfish user@server startkde
  • -X = forward X
  • -f = puts your ssh session into the background
  • -C = use compression -c blowfish = use blowfish (I am told this is the fastest)

If you are using ssh, be sure to understand the security risk, and I personally advise you use keys and disable password authentication.

If you want an entire desktop I would suggest FreeNX. FreeNX is both fast and secure.

https://help.ubuntu.com/community/FreeNX


If you're just talking about running a graphical application from the terminal, you can specify the DISPLAY environment value like so:

DISPLAY=:0 gcalctool

Or if you want it to persist you can export it to remain part of your bash session:

export DISPLAY=:0

I use freerdp-x11 that is front-ended by x2goclient and back-ended by x2goserver, if you are connecting to Linux machines, then the connection is established and secured by ssh.

This also enables shadowing.

Alternatively, xtightvncviewer is rather handy.

sudo apt clean && sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
sudo apt install freerdp-x11
sudo apt install x2goclient

For the x2goserver, depending on distro: https://wiki.x2go.org/doku.php/wiki:repositories:ubuntu

You might need to configure such things as this:

sudo ufw enable
sudo ufw allow ssh

Then all you need to do is launch the x2goclient, add in your parameters and pick the desktop type the host is using. For example, I use:

Parameters:

/cert-ignore /sound /multimedia /multimon +fonts

when connecting to a Windows terminal server.

The majority of Linux machines are using Lubuntu, which is LXDE, so I pick that and the resolution, the rest works automatically.