Ubuntu – Enable remote desktop on azure ubuntu

azuregnomeremote desktopsshxserver

A few day before I created a virtual ubuntu machine o my MS azure. I have an ssh connection (via PuTTY) to this machine, but I just cannot get the remote desktop working. Well in fact, I'm pretty new with linux, so please excuse me if I'm totally out.
So, I have installed ubuntu-desktop, created an end-point for remote desktop (port 3389), but when I try to run 'startx /usr/bin/gnome-session' (I wanted to run it as root, but the gnome-session didn't seem to like this idea…) it says me, that there is no .Xauthority file, although there is.

See:

$ ls -aF -l
total 104
drwxr-xr-x 17 ermidomus ermidomus  4096 Nov 16 14:07 ./
drwxr-xr-x  4 root      root       4096 Nov 13 20:14 ../
-rw-r--r--  1 ermidomus ermidomus   220 Apr  9  2014 .bash_logout
-rw-r--r--  1 ermidomus ermidomus  3637 Apr  9  2014 .bashrc
drwx------  9 ermidomus ermidomus  4096 Nov 15 02:16 .cache/
drwx------ 11 ermidomus ermidomus  4096 Nov 15 02:16 .config/
-rwxr-xr-x  1 root      root        137 Nov 15 15:42 createXauth.sh*
drwx------  3 ermidomus ermidomus  4096 Nov 13 21:22 .dbus/
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Desktop/
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Documents/
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Downloads/
drwx------  3 root      root       4096 Nov 15 02:17 .gconf/
drwx------  2 root      root       4096 Nov 15 02:16 .gvfs/
-rw-------  1 root      root        330 Nov 15 02:16 .ICEauthority
drwxr-xr-x  3 root      root       4096 Nov 15 02:16 .local/
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Music/
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Pictures/
-rw-r--r--  1 ermidomus ermidomus   675 Apr  9  2014 .profile
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Public/
-rw-r--r--  1 ermidomus ermidomus     0 Nov 13 22:20 .sudo_as_admin_successful
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Templates/
-rw-r--r--  1 root      root          0 Nov 14 23:49 test.txt
drwxr-xr-x  2 ermidomus ermidomus  4096 Nov 13 21:22 Videos/
drwx------  2 ermidomus ermidomus  4096 Nov 13 21:22 .vnc/
-rw-------  1 root      root          0 Nov 15 16:29 .Xauthority
-rw-------  2 ermidomus ermidomus     0 Nov 16 13:58 .Xauthority-c
-rw-------  2 ermidomus ermidomus     0 Nov 16 13:58 .Xauthority-l
-rw-r--r--  1 root      root          0 Nov 14 23:50 .xsession
-rw-------  1 ermidomus ermidomus 15935 Nov 15 10:36 .xsession-errors

Here is what it says:

$ startx /usr/bin/gnome-session
xauth:  timeout in locking authority file /home/ermidomus/.Xauthority
xauth:  timeout in locking authority file /home/ermidomus/.Xauthority

X: user not authorized to run the X server, aborting.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
xauth:  timeout in locking authority file /home/ermidomus/.Xauthority

I suppose, I have to re-create the .Xauthority file. But my main problem is, i have no idea how. After huge google research and finding some instructions, which didn't work, Iam turning for help here. So sorry, but I'm realy linux n00b and need very 'easy way' instructions.

Thank you all

Best Answer

Using this solution to rdp in my vm's in AWS and GCE clouds.

To remote desktop your Ubuntu machine, Install xrdp and xfce.

sudo apt-get update && sudo apt-get install xrdp && sudo apt-get install xfce4

Configure xrdp:

  1. Create .xsession in home directory.

    echo xfce4-session >~/.xsession
    
  2. Edit startup file for xrdp (notice that the last line is startxfce4)

    nano /etc/xrdp/startwm.sh
    

    enter image description here

  3. Restart xrdp service

    sudo service xrdp restart
    

Log in:

RDP to your remote machine and enter your Ubuntu credentials. You will be able to log in.

xrdp landing page

Note:

By default, each time you login with xrdp , it starts a new session.

To resume your previous session that you are already using:

  1. edit xrdp.ini file,

    sudo nano /etc/xrdp/xrdp.ini
    

    Search the [xrdp] section for the name sesman-Xvnc. (In my case it's [xrdp1]).

    enter image description here

    Change port value to ask (default is -1), then save and exit.

  2. Restart xrdp server

    sudo service xrdp restart
    
  3. RDP to your remote machine. You will see a login screen:

    enter image description here

  4. Log in with username, password and enter port as -1(for the first immediate session after xrdp restart).

  5. Note port number allocated carefully.

    enter image description here

  6. Next time use this port number to login to resume session.

    enter image description here

Source: Use XRDP to Remote-Access Ubuntu 14.04