Get a 4‑Core 16GB RAM FREE VPS with Root Access in Just 6 Minutes – No Credit Card Needed

Setting Up Google Chrome Remote Desktop on GitHub Codespaces

Welcome to this comprehensive tutorial on how to set up Google Chrome Remote Desktop (CRD) on a GitHub Codespace. This will allow you to access a Linux desktop environment remotely from your browser.

Glimpse of the Process

This tutorial will guide you through the following steps:

  1. Creating a GitHub Account: If you don't already have one, we'll start there.
  2. Creating a New Repository: A space to host your Codespace configuration.
  3. Setting Up Codespace: Launching a new Codespace instance and configuring it for optimal performance (16GB RAM).
  4. Creating a Python Script: This script will automate the CRD installation and setup.
  5. Running the Script: Executing the Python script to install and configure CRD.
  6. Accessing via Chrome Remote Desktop: Connecting to your newly configured remote desktop.

Step 1: Create a GitHub Account

If you don't have a GitHub account yet, head over to https://github.com/ and sign up. It's a quick and straightforward process.


Step 2: Create a New Repository

Once you're logged in, click the "+" button in the top right corner and select "New repository". Choose a name for your repository and click "Create repository".


Step 3: Set Up a GitHub Codespace

1. In your newly created repository, click on the "Code" button.
2. Go to the "Codespaces" tab.
3. Click "Create new codespace".

4. Change Runtime (Optional but Recommended for Performance):

  • Once your Codespace is created, you might have the default 8GB RAM. To increase it to 16GB (if available for your plan), click on the three dots in the bottom left corner.
  • Select "Codespace settings".
  • Look for the "Runtime" section and if you have an option for a machine with 16GB RAM, select it.
  • You'll likely be prompted to restart your Codespace for the changes to take effect. Click "Restart".


Step 4: Create and Edit the Python Script

1. Once your Codespace has restarted (if you changed the runtime), in the file explorer on the left, click the "New File" icon (+).
2. Give your file a random name, for example, setup_crd.py, making sure to add the .py extension to indicate it's a Python file. If Python is not already installed in your Codespace environment, it will likely prompt you to install it. Follow the instructions to install Python.
3. Now, copy the following code block and paste it into your newly created setup_crd.py file. This script automates the installation and configuration of Chrome Remote Desktop along with some other useful tools.

Click to copy:
import os
import subprocess
import shutil

CRD_SSH_Code = input("Google CRD SSH Code :")
username = "user" #@param {type:"string"}
password = "root" #@param {type:"string"}
os.system(f"useradd -m {username}")
os.system(f"adduser {username} sudo")
os.system(f"echo '{username}:{password}' | sudo chpasswd")
os.system("sed -i 's/\/bin\/sh/\/bin\/bash/g' /etc/passwd")

Pin = 123456 #@param {type: "integer"}
Autostart = True #@param {type: "boolean"}

class CRDSetup:
    def __init__(self, user):
        os.system("apt update")
        self.installCRD()
        self.installDesktopEnvironment()
        self.changewall()
        self.installGoogleChrome()
        self.installTelegram()
        self.installQbit()
        self.finish(user)

    @staticmethod
    def installCRD():
        subprocess.run(['wget', 'https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb'])
        subprocess.run(['dpkg', '--install', 'chrome-remote-desktop_current_amd64.deb'])
        subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'])
        print("Chrome Remoted Desktop Installed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

    @staticmethod
    def installDesktopEnvironment():
        os.system("export DEBIAN_FRONTEND=noninteractive")
        os.system("apt install --assume-yes xfce4 desktop-base xfce4-terminal")
        os.system("bash -c 'echo \"exec /etc/X11/Xsession /usr/bin/xfce4-session\" > /etc/chrome-remote-desktop-session'")
        os.system("apt remove --assume-yes gnome-terminal")
        os.system("apt install --assume-yes xscreensaver")
        os.system("sudo service lightdm stop")
        os.system("sudo apt-get install dbus-x11 -y")
        os.system("service dbus start")
        print("Installed XFCE4 Desktop Environment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

    @staticmethod
    def installGoogleChrome():
        subprocess.run(["wget", "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"])
        subprocess.run(["dpkg", "--install", "google-chrome-stable_current_amd64.deb"])
        subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'])
        print("Google Chrome Installed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

    @staticmethod
    def installTelegram():
        subprocess.run(["apt", "install", "--assume-yes", "telegram-desktop"])
        print("Telegram Installed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

    @staticmethod
    def changewall():
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/1280x1024.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/1280x1024.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/1280x800.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/1280x800.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/1600x1200.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/1600x1200.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/1920x1080.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/1920x1080.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/1920x1200.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/1920x1200.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/2560x1440.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/2560x1440.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/2560x1600.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/2560x1600.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/3200x1800.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/3200x1800.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/3200x2000.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/3200x2000.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/3840x2160.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/3840x2160.svg")
        os.system(f"sudo curl -s -L -o /etc/alternatives/desktop-theme/wallpaper/contents/images/5120x2880.svg https://gitlab.com/chamod12/gcrd_deb_codesandbox.io_rdp/-/raw/main/walls/5120x2880.svg")
        print("Wallpaper Changed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

    @staticmethod
    def installQbit():
        subprocess.run(["sudo", "apt", "update"])
        subprocess.run(["sudo", "apt", "install", "-y", "qbittorrent"])
        print("Qbittorrent Installed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

    @staticmethod
    def finish(user):
        if Autostart:
            os.makedirs(f"/home/{user}/.config/autostart", exist_ok=True)
            link = "www.youtube.com/@The_Disala"
            colab_autostart = """
print("Finalizing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

Type=Application
Name=Colab
Exec=sh -c "sensible-browser {}"
Icon=
Comment=Open a predefined notebook at session signin.
X-GNOME-Autostart-enabled=true""".format(link)
            with open(f"/home/{user}/.config/autostart/colab.desktop", "w") as f:
                f.write(colab_autostart)
            os.system(f"chmod +x /home/{user}/.config/autostart/colab.desktop")
            os.system(f"chown {user}:{user} /home/{user}/.config")

        os.system(f"adduser {user} chrome-remote-desktop")
        command = f"{CRD_SSH_Code} --pin={Pin}"
        os.system(f"su - {user} -c '{command}'")
        os.system("service chrome-remote-desktop start")

        print(" ..........................................................")
        print(" .....Brought By The Disala................................")
        print(" ..........................................................")
        print(" ......#####...######...####....####...##.......####.......")
        print(" ......##..##....##....##......##..##..##......##..##......")
        print(" ......##..##....##.....####...######..##......######......")
        print(" ......##..##....##........##..##..##..##......##..##......")
        print(" ......#####...######...####...##..##..######..##..##......")
        print(" ..........................................................")
        print(" ......... Telegram Channel - https://t.me/TheDisala4U ....")
        print(" ..........................................................")
        print(" ..Youtube Channel - https://www.youtube.com/@The_Disala ..")
        print(" ..........................................................")
        print("Log in PIN : 123456")
        print("User Name : user")
        print("User Pass : root")
        while True:
            pass

try:
    if CRD_SSH_Code == "":
        print("Please enter authcode from the given link")
    elif len(str(Pin)) < 6:
        print("Enter a pin more or equal to 6 digits")
    else:
        CRDSetup(username)
except NameError as e:
    print("'username' variable not found, Create a user first")
        

Step 5: Run the Python Script

1. Open the terminal in your Codespace (usually found at the bottom).
2. First, gain root access by typing the following command and pressing Enter:

sudo su

3. Now, navigate to the directory where you saved the setup_crd.py file (it should be in the main directory).
4. Run the script using the Python interpreter:

python setup_crd.py

5. The script will start executing and will prompt you to enter your Google CRD SSH Code.

  • Obtaining the CRD Code: To get this code, you'll need to temporarily install Chrome Remote Desktop on your local machine (if you haven't already) and visit the following link in your Chrome browser while logged into your Google account: https://remotedesktop.google.com/headless. Follow the on-screen instructions to generate an SSH command. Copy the authorization code part of that command. It will look something like ssh ... --authorize "YOUR_LONG_AUTHORIZATION_CODE" .... You only need the "YOUR_LONG_AUTHORIZATION_CODE" part.

6. Paste the authorization code when prompted in the Codespace terminal and press Enter.
7. The script will continue to install the necessary components, including the XFCE4 desktop environment, Google Chrome, and Telegram. It will also configure the Chrome Remote Desktop service. This process might take some time.


Step 6: Accessing via Chrome Remote Desktop

1. Once the script has finished running (you'll see the "Log in PIN", "User Name", and "User Pass" messages), open a new tab in your local Chrome browser.
2. Go to https://remotedesktop.google.com/access/ and log in with the same Google account you used to generate the SSH code.
3. You should see your GitHub Codespace listed as a remote computer. Click on it.
4. Enter the PIN that was displayed at the end of the script's output in your Codespace terminal (default is 123456).
5. Click "Connect".

You should now have access to the graphical desktop environment running in your GitHub Codespace within your Chrome browser!


Important Notes:

  • Keep your Codespace running if you want to maintain remote access. Codespaces may automatically stop after a period of inactivity, depending on your settings.
  • The default username is user and the default password is root. You can modify these in the script if desired before running it. Exercise caution when changing default passwords and ensure they are strong.
  • The script also installs Telegram and qBittorrent, and sets a default wallpaper.
  • The script attempts to set up an autostart link to a YouTube channel.