import os import subprocess # Check if the script is run as root if os.geteuid() != 0: print("This script must be run as root or with sudo privileges.") exit(1) # SSH command for Chrome Remote Desktop (using your provided code) SSH_CMD = 'DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AQSTgQFQ11X0tzx6SBSwlpBf19zPm0VKYYg50D2EoOROivJ1paJXfnSeivNwakWwGFGrgg" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)' # User configuration (modify as needed) username = "user" password = "root" # Create user and update shell os.system(f"useradd -m {username}") os.system(f"adduser {username} sudo") os.system(f"echo '{username}:{password}' | chpasswd") os.system("sed -i 's/\\/bin\\/sh/\\/bin\\/bash/g' /etc/passwd") # CRD PIN and autostart flag Pin = 123456 Autostart = True class CRDSetup: def __init__(self, user): os.system("apt update") self.installCRD() self.installDesktopEnvironment() self.installBrave() self.finish(user) @staticmethod def installCRD(): try: subprocess.run(['wget', 'https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb'], check=True) subprocess.run(['dpkg', '--install', 'chrome-remote-desktop_current_amd64.deb'], check=True) subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'], check=True) print("Chrome Remote Desktop Installed!") except subprocess.CalledProcessError as e: print(f"Error installing Chrome Remote Desktop: {e}") exit(1) @staticmethod def installDesktopEnvironment(): os.system("apt install --assume-yes dbus-x11") 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("apt purge --assume-yes light-locker") os.system("apt install --assume-yes --reinstall xfce4-screensaver") os.system("systemctl disable lightdm.service") print("Installed XFCE4 Desktop Environment!") @staticmethod def installBrave(): try: subprocess.run(['apt', 'install', '--assume-yes', 'apt-transport-https', 'curl'], check=True) subprocess.run(['curl', '-fsSLo', '/usr/share/keyrings/brave-browser-archive-keyring.gpg', 'https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg'], check=True) subprocess.run(['bash', '-c', 'echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" > /etc/apt/sources.list.d/brave-browser-release.list'], check=True) subprocess.run(['apt', 'update'], check=True) subprocess.run(['apt', 'install', '--assume-yes', 'brave-browser'], check=True) print("Brave Browser Installed!") except subprocess.CalledProcessError as e: print(f"Error installing Brave Browser: {e}") exit(1) @staticmethod def finish(user): if Autostart: os.makedirs(f"/home/{user}/.config/autostart", exist_ok=True) autostart_entry = """[Desktop Entry] Type=Application Name=Brave Browser Exec=brave-browser Icon= Comment=Open Brave at startup. X-GNOME-Autostart-enabled=true""" with open(f"/home/{user}/.config/autostart/brave.desktop", "w") as f: f.write(autostart_entry) os.system(f"chmod +x /home/{user}/.config/autostart/brave.desktop") os.system(f"chown {user}:{user} /home/{user}/.config") os.system(f"adduser {user} chrome-remote-desktop") os.system(f"su - {user} -c '{SSH_CMD} --pin={Pin}'") os.system("service chrome-remote-desktop start") print("Setup complete. You can now connect via Chrome Remote Desktop.") print(f"Log in PIN: {Pin}") print(f"User Name: {user}") print(f"User Pass: {password}") # Keep the container running while True: pass CRDSetup(username)