10

I am considering creating a Debian VM on Google Cloud. Here are the newbie instructions:

https://cloud.google.com/compute/docs/quickstart-linux

It says in that article in the "Connect to your instance" section that I can connect to the instance using SSH. Is this terminal interface text-only? Or is there an option to connect to the instance using a GUI of some sort?

Thanks.

[edit]

I should say that I need to be able to see and manipulate the desktop, like with Microsoft's RDP.

5
  • That's a deal-breaker, unfortunately. I'm trying to run some raytracing software, and definitely need to be able to see the rendered output. I would vote your post as the answer.
    – posfan12
    Commented Apr 10, 2017 at 4:48
  • 2
    Please make sure you read also my answer, which differs from the one you just received. Commented Apr 10, 2017 at 8:29
  • Could you not just render the output and transmit it to your local machine, then look at it there?
    – slhck
    Commented Apr 10, 2017 at 8:30
  • No, I need to see the partial incomplete output before the render is 100% done. An actual file is not generated until 100% completion.
    – posfan12
    Commented Apr 10, 2017 at 22:44
  • I found this for Debian cloud.google.com/solutions/…
    – f01
    Commented Jul 8, 2019 at 1:24

1 Answer 1

8

You can definitely have a GUI on your VM. It just requires a minimum setup.

The easiest is to use a Linux/Unix (Mac included) pc to access your VM, because then all you need to do is the following:

  1. On the VM, edit the file /etc/ssh/sshd_config, and make sure you have these two lines:

    X11Forwarding yes
    X11DisplayOffset 10
    

    and restart the ssh daemon,

    sudo systemctl force-reload ssh
    

    (On a Mac, that would be:

    sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
    sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
    

    while on an old Linux or a Unix that would be:

    sudo /etc/init.d/ssh restart
    

    ).

  2. On your Linux/Unix pc, connect with the command:

    ssh -Y [email protected]
    

    then on the VM make sure the graphical display is correctly selected,

    export DISPLAY=localhost:10.0
    

    and now from within the ssh session you can start graphical applications which will be displayed on your Linux pc monitor. Try, for instance,

    xeyes
    

In line of principle, there is a way to start a whole Desktop Environment (KDE, Gnome, Xfce, Enlightenment, you name it) on the VM, and have it displayed on your Linux pc, but this requires very large bandwidths, so I will not tell you how to do it unless you explicitly ask.

The reason why you were not initially offered this solution is that most people seem to forget that Xorg, the Linux graphical interface, is a server, i.e. it performs the service of displaying on the monitor it is running on the graphical applications which send it data, whether they come from the local or a remote pc. So your Xorg session is perfectly capable of doing this.

If instead you are connecting from a Windows pc, vnc will do that for you, but this requires that you have an Xorg session on the VM, to which vnc connects and replicates it locally, albeit with much worse resolution. If this what you wish to do, you may read here.

EDIT:

a reply to Vidya's comment below. The following assumes you already have a graphical desktop installed on your VM, KDE, Gnome, or what not.

I like this connection to be shown in a window of its own, which I can resize, move, fold, or maximize as need be. So I use Xephyr: on your home computer running any Linux, first you will have to install it,

sudo apt-get install xserver-xephyr

(this command is suitable for Debian and derivatives, if you use a diffent distro you will have to use a suitable package manager), then you start it with

Xephyr -ac -br :1 -resizeable &

(please notice the capital X here, not in the install package), where the important options are :1 (this is what your new display will be called) and resizeable, which allows you to modify the window as per your wishes.

Now you can start your remote session to your server with:

DISPLAY=:1.0 ssh -Y [email protected]

and, once you are inside the virtual machine a command suitable to your display manager, like startkde (if you have KDE), or startx and so on will start your graphical session inside the Xephyr window. If you want, before starting the graphical session, you can just start a simple applications like xeyes which is very fast to load, and should open in the Xephyr window. When you are done, just kill the Xephyr window, that's it.

2
  • I know it's been a while, but I would love to hear how to view the whole VM Desktop Environment displayed on the client.
    – Vidya
    Commented Dec 6, 2017 at 15:32
  • @Vidya Pls read my Edit. Commented Dec 6, 2017 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .