How to open the display from ssh login?

68,792

Solution 1

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

Solution 2

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

Solution 3

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.

Share:
68,792

Related videos on Youtube

idiot
Author by

idiot

I am a student and a guy who likes to explore.

Updated on September 18, 2022

Comments

  • idiot
    idiot almost 2 years

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

  • Andy
    Andy over 10 years
    Looks like the only works when the display is opened by the same user who is running this command. Can it be done w/o su to the user who is logged into the display?
  • abu_bua
    abu_bua almost 6 years
    Welcome to Ask Ubuntu! I recommend to edit your question to expand it with specific details about what you do.
  • IT Gremlin
    IT Gremlin almost 6 years
    Done. 987654321 chars