Skip to content

Instantly share code, notes, and snippets.

@Udara-Dananjaya
Last active September 20, 2023 09:45
Show Gist options
  • Save Udara-Dananjaya/b77d28bc12182e4998ea5d18b1411b05 to your computer and use it in GitHub Desktop.
Save Udara-Dananjaya/b77d28bc12182e4998ea5d18b1411b05 to your computer and use it in GitHub Desktop.
Ubuntu RDP Setup: Configure swap, SSH, remote desktop, tools installation for a comprehensive remote computing environment.
# This script automates the setup and configuration of various applications on Ubuntu.
# Ensure superuser privileges
sudo -i
# Create a swap area to improve system performance
sudo dd if=/dev/zero bs=1M count=5024 of=/mnt/swapfile.swap
sudo chmod 600 /mnt/swapfile.swap
sudo mkswap /mnt/swapfile.swap
sudo swapon /mnt/swapfile.swap
echo '/mnt/swapfile.swap swap swap defaults 0 0' | sudo tee -a /etc/fstab
# Display system memory and storage information
free -m
df -h
# Update the list of available packages
sudo apt update -y
# Upgrade installed packages
sudo apt-get upgrade -y
sudo apt-get full-upgrade -y
# Fix GRUB-EFI error by reinstalling GRUB
sudo apt-get purge grub\*
sudo apt install -y grub-efi-arm64
# Create a new user with SSH access and set up firewall rules
sudo -s
adduser username
sudo usermod -aG sudo username
sudo ufw app list
sudo ufw allow OpenSSH
sudo ufw enable
# Proceed with operation (y|n)? y
sudo ufw status
sudo nano /etc/ssh/sshd_config
# Enable PasswordAuthentication if needed
#PasswordAuthentication yes
sudo ufw reload
sudo service ssh restart
sudo ssh username@your_server_ip
# Set a password for the new user
sudo passwd ubuntu
# Remove password requirement for the user
sudo passwd -d ubuntu
# Install Chrome Remote Desktop for remote access
sudo apt update -y
sudo apt install -y wget
sudo wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
sudo dpkg --install chrome-remote-desktop_current_amd64.deb
sudo apt install -y --fix-broken
sudo DEBIAN_FRONTEND=noninteractive apt install -y xfce4 desktop-base
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session'
sudo apt install -y xscreensaver
sudo groupadd chrome-remote-desktop
sudo usermod -a -G chrome-remote-desktop $USER
# Install XRDP for direct remote desktop access
sudo apt update -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y xfce4 desktop-base
sudo apt install -y xrdp
systemctl status xrdp
sudo nano /etc/xrdp/xrdp.ini
# Change RDP port if needed (default is port 3389)
#port=tcp://:3389
systemctl restart xrdp
# Configure IPTABLES firewall rules
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F
# Install Webmin for web-based system administration
sudo apt update -y
sudo wget https://github.com/webmin/webmin/releases/download/2.102/webmin_2.102_all.deb
sudo dpkg --install webmin_2.102_all.deb
sudo apt install -y --fix-broken
sudo ufw allow 10000/tcp
# Access Webmin at https://ip-address:10000
# Install Cockpit for managing the system through a web-based interface
sudo apt update -y
sudo apt install -y cockpit
sudo apt install cockpit-packagekit
sudo apt install cockpit-machines
sudo systemctl start cockpit cockpit.socket
sudo systemctl enable cockpit cockpit.socket
sudo ufw allow 9090
# Access Cockpit at https://ip-address:9090
# Install net-tools for network-related commands
sudo apt update -y
sudo apt install -y net-tools
# Restart PulseAudio to fix audio issues
killall pulseaudio; pulseaudio -k; rm -r ~/.config/pulse/*; rm -r ~/.pulse*
pulseaudio --start
# Install GNOME System Monitor for task management
sudo apt update -y
sudo apt-get install gnome-system-monitor
# Install Google Chrome browser
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
# Install Google Chrome Dev browser
wget https://dl.google.com/linux/direct/google-chrome-unstable_current_amd64.deb
sudo apt install ./google-chrome-unstable_current_amd64.deb
# Install Wine for running Windows applications on Linux
sudo dpkg --add-architecture i386
sudo apt update -y
sudo apt install wine64 wine32
wine --version
# Install VLC media player
sudo snap install vlc
sudo apt update -y
sudo apt install vlc
# Install Visual Studio Code (VSCode)
sudo apt update -y
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt install code
sudo apt update -y
sudo apt upgrade -y
# Install OpenJDK 11 (Java)
sudo apt update -y
sudo apt install openjdk-11-jdk
java -version
# Install Python 3.9
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9
python3.9 --version
# Install LibreOffice productivity suite
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt update
sudo apt install libreoffice
# Clear different levels of cache to free up memory
sync; echo 1 > /proc/sys/vm/drop_caches # Clear PageCache only
sync; echo 2 > /proc/sys/vm/drop_caches # Clear dentries and inodes
sync; echo 3 > /proc/sys/vm/drop_caches # Clear PageCache, dentries, and inodes
# Perform system cleanup
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get clean
# Display the size of APT cache
sudo du -sh /var/cache/apt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment