azurevirtual-machineremote-desktopazure-bastion

Accessing AZURE VM GUI {linux} from local PC {windows} without using Bastion


I recently created an Azure Virtual Machine {Linux} with GPU for research purpose, I have installed a software on the VM using Powershell from my Desktop, and now I need to view it using GUI.

I cannot afford to buy Bastion, as it's quite expensive. Is there a way I can connect to the VM using my local desktop directly.

I am new to this and I would appreciate any assistance you can provide. I have tried using ChatGTP to provide some answers but non of them worked.

Please help me with this if you have any code/ website/ guide please let me know.


Solution

  • To log in to a Linux virtual machine with a GUI
    you first need to assign a public IP to the machine. After that, connect to the Linux machine using the SSH port through the command prompt. Make sure to add the SSH port to the inbound rules in the Network Security Group (NSG).
    enter image description here

    After that, open the Command Prompt as an administrator on your local Windows machine and connect using the command below.
    ssh <Username>@<Public IP of your VM>
    enter image description here
    After connecting to the Azure Linux machine, I ran the following commands to install XRDP and the XFCE desktop environment.

    Update Your System
    sudo apt update && sudo apt upgrade -y

    Install XFCE Desktop Environment:
    sudo apt install xfce4 xfce4-goodies -y

    Install xRDP
    sudo apt install xrdp -y

    Start and Enable xRDP Service
    sudo systemctl enable xrdp

    And start the Xrdp by using below command
    sudo systemctl start xrdp

    Check XRDP Status
    sudo systemctl status xrdp

    Configure Firewall to Allow RDP Traffic (Port 3389)

    sudo ufw allow 3389/tcp
    sudo ufw reload

    Make sure to add RDP port 3389 to the inbound rules of the Network Security Group to access the GUI.

    enter image description here

    I successfully logged in using RDP. Please see the images below for your reference.
    Output:
    enter image description here

    enter image description here

    References: https://www.digitalocean.com/community/tutorials/how-to-enable-remote-desktop-protocol-using-xrdp-on-ubuntu-22-04

    https://learn.microsoft.com/en-us/azure/virtual-machines/linux/use-remote-desktop?tabs=azure-cli