Long Time RDP

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Develop With Nitin (YouTube Channel)

Dont Forget to Like And


Subscribe........................................................please
Step 1 :- https://deepnote.com/

Stept 2:-http://remotedesktop.google.com/headless

first Program :-

import os
username = "user" #@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")

Second program:-

import os
import subprocess

CRP = "DISPLAY= /opt/google/chrome-remote-desktop/start-host --code=\"4/0AY0e-


g6FTDvufTIuXV0C9s9Q3_2LMoZfHeP3Yw5t_jzGbfuAzRvw4Mbo7VFAtYDdKifbdw\" --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/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():
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/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():
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")

...................................................................................
......

Dont Forget to Like And Subscribe


...................................................................................
.......

You might also like