Skip to content

Instantly share code, notes, and snippets.

@JoyGhoshs
Created December 27, 2021 11:13
Show Gist options
  • Save JoyGhoshs/19e36bab956d6960ac4dd90e12e9a892 to your computer and use it in GitHub Desktop.
Save JoyGhoshs/19e36bab956d6960ac4dd90e12e9a892 to your computer and use it in GitHub Desktop.
class RDP:
def __init__(self):
os.system("apt update")
self.installRDP()
self.installDesktopEnvironment()
self.installGoogleChorme()
self.finish()
@staticmethod
def installRDP():
subprocess.run(['wget', 'https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb'], 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():
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():
subprocess.run(["wget", "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"], 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():
os.system(f"adduser {user} chrome-remote-desktop")
command = f"{Command} --pin={Pin}"
os.system(f"su - {user} -c '{command}'")
os.system("service chrome-remote-desktop start")
try:
if user:
if Command == "":
print("Please enter authcode from the given link")
elif len(str(Pin)) < 6:
print("Enter a pin more or equal to 6 digits")
else:
RDP()
except NameError as e:
print("user variable not found")
print("Create a User First")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment