import os
import subprocess
CRP = "DISPLAY= /opt/google/chrome-remote-desktop/start-host --code=\"4/0AX4XfWjqlHqV7k1bLJFGP9-2w3zfYSceHDS9tYRXdUadfYKtX8zgJR8CB_IvSJATNm6ioA\" --redirect-url=\"https://remotedesktop.google.com/_/oauthredirect\" --name=$(hostname)" #paste your rdp link
Pin = 123456 #pin
class CRD:
def __init__(self):
os.system("apt update")
self.installCRD()
self.installDesktopEnvironment()
self.installGoogleChorme()
self.finish()
@staticmethod
def installCRD():
print("Installing Chrome Remote Desktop")
subprocess.run(['wget', 'https://dl.google.com/.../chrome-remote-desktop_current...'], stdout=subprocess.PIPE)
subprocess.run(['dpkg', '--install', 'chrome-remote-desktop_current_amd64.deb'], stdout=subprocess.PIPE)
subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'], stdout=subprocess.PIPE)
@staticmethod
def installDesktopEnvironment():
print("Installing Desktop Environment")
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("systemctl disable lightdm.service")
@staticmethod
def installGoogleChorme():
print("Installing Google Chrome")
subprocess.run(["wget", "https://dl.google.com/.../google-chrome-stable_current..."], stdout=subprocess.PIPE)
subprocess.run(["dpkg", "--install", "google-chrome-stable_current_amd64.deb"], stdout=subprocess.PIPE)
subprocess.run(['apt', 'install', '--assume-yes', '--fix-broken'], stdout=subprocess.PIPE)
@staticmethod
def finish():
print("Finalizing")
os.system(f"adduser {username} chrome-remote-desktop")
command = f"{CRP} --pin={Pin}"
os.system(f"su - {username} -c '{command}'")
os.system("service chrome-remote-desktop start")
print("Finished Succesfully")
try:
if username:
if CRP == "":
print("Please enter authcode from the given link")
elif len(str(Pin)) < 6:
print("Enter a pin more or equal to 6 digits")
else:
CRD()
except NameError as e:
print("username variable not found")
print("Create a User First")
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Hit:1 http://security.debian.org/debian-security buster/updates InRelease
Hit:2 http://deb.debian.org/debian buster InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Reading package lists...
Building dependency tree...
Reading state information...
6 packages can be upgraded. Run 'apt list --upgradable' to see them.
Installing Chrome Remote Desktop
--2021-07-26 04:10:58-- https://dl.google.com/.../chrome-remote-desktop_current...
Resolving dl.google.com (dl.google.com)... 142.250.188.206, 2607:f8b0:4004:807::200e
Connecting to dl.google.com (dl.google.com)|142.250.188.206|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-07-26 04:10:58 ERROR 404: Not Found.
dpkg: error: cannot access archive 'chrome-remote-desktop_current_amd64.deb': No such file or directory
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Installing Desktop Environment
Reading package lists...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Building dependency tree...
Reading state information...
desktop-base is already the newest version (10.0.2).
xfce4 is already the newest version (4.12.5).
xfce4-terminal is already the newest version (0.8.7.4-2).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Reading package lists...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Building dependency tree...
Reading state information...
Package 'gnome-terminal' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Reading package lists...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Building dependency tree...
Reading state information...
xscreensaver is already the newest version (5.42+dfsg1-1).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Installing Google Chrome
Synchronizing state of lightdm.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable lightdm
--2021-07-26 04:11:02-- https://dl.google.com/.../google-chrome-stable_current...
Resolving dl.google.com (dl.google.com)... 142.250.65.78, 2607:f8b0:4004:82f::200e
Connecting to dl.google.com (dl.google.com)|142.250.65.78|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-07-26 04:11:03 ERROR 404: Not Found.
dpkg: error: cannot access archive 'google-chrome-stable_current_amd64.deb': No such file or directory
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Finalizing
Finished Succesfully
adduser: The group `chrome-remote-desktop' does not exist.
-bash: /opt/google/chrome-remote-desktop/start-host: No such file or directory
chrome-remote-desktop: unrecognized service
import os
username = "user1" #@param {type:"string"}
password = "root" #@param {type:"string"}
print("Creating User and Setting it up")
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")
print("User Created and Configured")
Creating User and Setting it up
Adding user `user1' to group `sudo' ...
Adding user user1 to group sudo
Done.
User Created and Configured