Created
January 13, 2021 20:47
-
-
Save orangemn6/c2d82547edda114faff49a579bf3e6f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "name": "Remote Linux", | |
| "provenance": [], | |
| "collapsed_sections": [], | |
| "authorship_tag": "ABX9TyP77bvqNYDDSSAxBlx1tChH", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| }, | |
| "accelerator": "GPU" | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/orangemn6/e223b04866179466ccf232eb0e63e8e2/health-notes.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "uZuwWq2JywOo" | |
| }, | |
| "source": [ | |
| "" | |
| ], | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "ydTQCsvQt5RQ", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "outputId": "59b68f9c-33ba-4f72-b3a4-e2521c2f7ffa" | |
| }, | |
| "source": [ | |
| "#@title **Create User**\n", | |
| "#@markdown Enter Username and Password\n", | |
| "\n", | |
| "username = \"user\" #@param {type:\"string\"}\n", | |
| "password = \"root\" #@param {type:\"string\"}\n", | |
| "\n", | |
| "print(\"Creating User and Setting it up\")\n", | |
| "\n", | |
| "# Creation of user\n", | |
| "! sudo useradd -m $username &> /dev/null\n", | |
| "\n", | |
| "# Add user to sudo group\n", | |
| "! sudo adduser $username sudo &> /dev/null\n", | |
| " \n", | |
| "# Set password of user to 'root'\n", | |
| "! echo '$username:$password' | sudo chpasswd\n", | |
| "\n", | |
| "# Change default shell from sh to bash\n", | |
| "! sed -i 's/\\/bin\\/sh/\\/bin\\/bash/g' /etc/passwd\n", | |
| "\n", | |
| "print(\"User Created and Configured\")\n", | |
| "\n", | |
| "\n", | |
| "#@title **RDP**\n", | |
| "#@markdown It takes 4-5 minutes for installation\n", | |
| "\n", | |
| "#@markdown Visit http://remotedesktop.google.com/headless and Copy the command after authentication\n", | |
| "\n", | |
| "CRP = \"DISPLAY= /opt/google/chrome-remote-desktop/start-host --code=\\\"4/0AY0e-g6wxn7Gp-BF1VY_11ERzlvmcZkbeQZKnHverM5ftV7Gs-_Iqn2FZcdWvsooL1WZHQ\\\" --redirect-url=\\\"https://remotedesktop.google.com/_/oauthredirect\\\" --name=$(hostname)\" #@param {type:\"string\"}\n", | |
| "\n", | |
| "def CRD():\n", | |
| " with open('install.sh', 'w') as script:\n", | |
| " script.write(\"\"\"#! /bin/bash\n", | |
| "\n", | |
| "b='\\033[1m'\n", | |
| "r='\\E[31m'\n", | |
| "g='\\E[32m'\n", | |
| "c='\\E[36m'\n", | |
| "endc='\\E[0m'\n", | |
| "enda='\\033[0m'\n", | |
| "\n", | |
| "printf \"\\n\\n$c$b Loading Installer $endc$enda\" >&2\n", | |
| "if sudo apt-get update &> /dev/null\n", | |
| "then\n", | |
| " printf \"\\r$g$b Installer Loaded $endc$enda\\n\" >&2\n", | |
| "else\n", | |
| " printf \"\\r$r$b Error Occured $endc$enda\\n\" >&2\n", | |
| " exit\n", | |
| "fi\n", | |
| "\n", | |
| "printf \"\\n$g$b Installing Chrome Remote Desktop $endc$enda\" >&2\n", | |
| "{\n", | |
| " wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb\n", | |
| " sudo dpkg --install chrome-remote-desktop_current_amd64.deb\n", | |
| " sudo apt install --assume-yes --fix-broken\n", | |
| "} &> /dev/null &&\n", | |
| "printf \"\\r$c$b Chrome Remote Desktop Installed $endc$enda\\n\" >&2 ||\n", | |
| "{ printf \"\\r$r$b Error Occured $endc$enda\\n\" >&2; exit; }\n", | |
| "sleep 3\n", | |
| "\n", | |
| "printf \"$g$b Installing Desktop Environment $endc$enda\" >&2\n", | |
| "{\n", | |
| " sudo DEBIAN_FRONTEND=noninteractive \\\n", | |
| " apt install --assume-yes xfce4 desktop-base\n", | |
| " sudo bash -c 'echo \"exec /etc/X11/Xsession /usr/bin/xfce4-session\" > /etc/chrome-remote-desktop-session' \n", | |
| " sudo apt install --assume-yes xscreensaver\n", | |
| " sudo systemctl disable lightdm.service\n", | |
| "} &> /dev/null &&\n", | |
| "printf \"\\r$c$b Desktop Environment Installed $endc$enda\\n\" >&2 ||\n", | |
| "{ printf \"\\r$r$b Error Occured $endc$enda\\n\" >&2; exit; }\n", | |
| "sleep 3\n", | |
| "\n", | |
| "printf \"$g$b Installing Google Chrome $endc$enda\" >&2\n", | |
| "{\n", | |
| " wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb\n", | |
| " sudo dpkg --install google-chrome-stable_current_amd64.deb\n", | |
| " sudo apt install --assume-yes --fix-broken\n", | |
| "} &> /dev/null &&\n", | |
| "printf \"\\r$c$b Google Chrome Installed $endc$enda\\n\" >&2 ||\n", | |
| "printf \"\\r$r$b Error Occured $endc$enda\\n\" >&2\n", | |
| "sleep 3\n", | |
| "\n", | |
| "printf \"$g$b Installing other Tools $endc$enda\" >&2\n", | |
| "if sudo apt install nautilus nano -y &> /dev/null\n", | |
| "then\n", | |
| " printf \"\\r$c$b Other Tools Installed $endc$enda\\n\" >&2\n", | |
| "else\n", | |
| " printf \"\\r$r$b Error Occured $endc$enda\\n\" >&2\n", | |
| "fi\n", | |
| "sleep 3\n", | |
| "\n", | |
| "printf \"\\n$g$b Installation Completed $endc$enda\\n\\n\" >&2\"\"\")\n", | |
| "\n", | |
| " ! chmod +x install.sh\n", | |
| " ! ./install.sh\n", | |
| "\n", | |
| " # Adding user to CRP group\n", | |
| " ! sudo adduser $username chrome-remote-desktop &> /dev/null\n", | |
| "\n", | |
| " # Finishing Work\n", | |
| " ! su - $username -c \"\"\"$CRP\"\"\"\n", | |
| "\n", | |
| " print(\"Finished Succesfully\")\n", | |
| "\n", | |
| "try:\n", | |
| " if username:\n", | |
| " if CRP == \"\" :\n", | |
| " print(\"Please enter authcode from the given link\")\n", | |
| " else:\n", | |
| " CRD()\n", | |
| "except NameError:\n", | |
| " print(\"username variable not found\")\n", | |
| " print(\"Create a User First\")\n" | |
| ], | |
| "execution_count": null, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": [ | |
| "Creating User and Setting it up\n", | |
| "User Created and Configured\n", | |
| "\n", | |
| "\n", | |
| "\u001b[32m\u001b[1m Installer Loaded \u001b[0m\u001b[0m\n", | |
| "\n", | |
| "\u001b[36m\u001b[1m Chrome Remote Desktop Installed \u001b[0m\u001b[0m\n", | |
| "\u001b[36m\u001b[1m Desktop Environment Installed \u001b[0m\u001b[0m\n", | |
| "\u001b[36m\u001b[1m Google Chrome Installed \u001b[0m\u001b[0m\n", | |
| "\u001b[36m\u001b[1m Other Tools Installed \u001b[0m\u001b[0m\n", | |
| "\n", | |
| "\u001b[32m\u001b[1m Installation Completed \u001b[0m\u001b[0m\n", | |
| "\n", | |
| "Enter a PIN of at least six digits: \n", | |
| "Enter the same PIN again: \n", | |
| "[0112/133718.811278:ERROR:cert_verify_proc_builtin.cc(559)] No net_fetcher for performing AIA chasing.\n", | |
| "[0112/133718.878992:WARNING:host_config.cc(54)] Failed to read /home/user/.config/chrome-remote-desktop/host#b2dc16243aecc6263fa38567f46022db.json\n", | |
| "[0112/133719.002269:ERROR:cert_verify_proc_builtin.cc(559)] No net_fetcher for performing AIA chasing.\n", | |
| "[0112/133719.646500:INFO:daemon_controller_delegate_linux.cc(99)] 2021-01-12 13:37:19,637:INFO:User 'user' is already a member of 'chrome-remote-desktop'.\n", | |
| "\n", | |
| "[0112/133721.627373:INFO:daemon_controller_delegate_linux.cc(99)] [0112/133719.744675:INFO:remoting_user_session.cc(754)] Daemon process started in the background, logging to '/tmp/chrome_remote_desktop_20210112_133719_spD0P8'\n", | |
| "Using host_id: 457dc9fb-0b6f-4374-b518-0508f49792dd\n", | |
| "Launching X server and X session.\n", | |
| "Starting Xvfb on display :20\n", | |
| "X server is active.\n", | |
| "Launching X session: ['/bin/sh', '/etc/chrome-remote-desktop-session']\n", | |
| "Launching host process\n", | |
| "['/opt/google/chrome-remote-desktop/chrome-remote-desktop-host', '--host-config=-', '--audio-pipe-name=/home/user/.config/chrome-remote-desktop/pulseaudio#b2dc16243a/fifo_output', '--server-supports-exact-resize', '--ssh-auth-sockname=/tmp/chromoting.user.ssh_auth_sock', '--signal-parent']\n", | |
| "Host ready to receive connections.\n", | |
| "Log file: /tmp/chrome_remote_desktop_20210112_133719_spD0P8\n", | |
| "\n", | |
| "Finished Succesfully\n" | |
| ], | |
| "name": "stdout" | |
| } | |
| ] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment