Launch and Configure Debian with GUI Desktop

  • 1  Go to the Virtual machine service in the Azure portal.
  • 2  Click 'Add' -> 'Virtual Machine'.
  • 3  Under Image click on 'See all images'. Search for 'debian gui' and select our 'Debian with GUI Desktop' solution.
  • 3  We will use Username 'azureuser' when creating the Virtual Machine
  • 4  We use password authentification for the admin account as this password will also be needed when unlock from screensaver in the GUI. Fill out all other needed informations as you require and create the Virtual Machine.
  • 5  Note: By default, the servers network ports for SSH, VNC and RDP are open to the world. You can restrict access (e.g. only allow access from your local IP address) under selected VM -> Network
  • 6  Next, we need to run a bash script to configure the VM for the first usage. Copy and paste the following script into selected VM -> Run Commmand. Please change the password (first line in script) to another one you like. It must be 8 chars long. Note: When you created the VM with another username than 'azureuser' you need to replace the username in this script.
    password="Noricum1"
    
    sudo -H -u azureuser bash -c "mkdir /home/azureuser/.vnc"
    sudo -H -u azureuser bash -c "echo $password | vncpasswd -f > /home/azureuser/.vnc/passwd"
    sudo -H -u azureuser bash -c "chmod 400 /home/azureuser/.vnc/passwd"
    sudo -H -u azureuser bash -c "echo 'unset SESSION_MANAGER\nunset DBUS_SESSION_BUS_ADDRESS\nstartxfce4 &' > /home/azureuser/.vnc/xstartup"
    sudo -H -u azureuser bash -c "chmod 755 /home/azureuser/.vnc/xstartup"
    
    sudo -H -u azureuser bash -c "printf '#!/usr/bin/env bash\nvncserver -kill :1\nvncserver :1 -geometry 1400x800\nsudo systemctl restart xrdp' > /home/azureuser/.vnc/startVNC.sh"
    sudo -H -u azureuser bash -c "{ crontab -l -u azureuser; echo '@reboot sudo -H -u azureuser bash  /home/azureuser/.vnc/startVNC.sh'; } | crontab -u azureuser -"
    sudo -H -u azureuser bash -c "chmod 755 /home/azureuser/.vnc/startVNC.sh"
    
    sudo -H -u azureuser bash -c "vncserver"
    sudo -H -u azureuser bash -c "sudo systemctl restart xrdp"
    The script sets the password (1st paragraph), creates a cronjob to automatically start the GUI on reboot and finally launches VNC and RDP for the first time usage.


Connect to your Linux instance via RDP or VNC:

  • 1  Please see above section "Launch and Configure Debian with GUI Desktop" before continuing here.
  • 2  Get the public IP address of your Virtual Machine:

  • Open Remote Desktop Connection application on your local device, Select 'RDP', enter the Public IP address of your VM, username 'azureuser' and your set password and click on 'Connect'.
    Open a VNC client on your local device, Select 'VNC', enter the Public IP address of your VM, your set password and click on 'Connect'.


Manage VNC server:

  • 1  When you reboot your instance, a cronjob script starts RDP and VNC automatically. To change the script, connect to the terminal via SSH and log into your created user ('azureuser' in this documentation). See here how.
  • 2  The startup script is located at /home/azureuser/.vnc/startVNC.sh
    To edit the script, type
    nano /home/azureuser/.vnc/startVNC.sh

  • 5 If you want to edit the display size of the desktop, change the X/Y display size in the start command to
    vncserver -geometry 1500x800
    and reboot the VM by
    sudo reboot


Connect to your Linux instance via SSH: