Created
November 20, 2024 05:46
-
-
Save chris-gillatt/33b0fcf55754d531a0944f9dfea3f77a to your computer and use it in GitHub Desktop.
currently untested
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
| #!/bin/bash -e | |
| USER_NAME=user | |
| USER_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12}) | |
| # Create the non-root user | |
| echo "Creating user '${USER_NAME}'..." | |
| useradd -m -G wheel,adm,cdrom,sudo,dip,plugdev $USER_NAME | |
| # Set user password if provided | |
| if [[ -n $USER_PASSWORD ]]; then | |
| echo "${USER_NAME}:${USER_PASSWORD}" | chpasswd | |
| else | |
| echo "No password set for ${USER_NAME}. You can set it manually using 'passwd ${USER_NAME}'." | |
| fi | |
| echo "add user $USER_NAME" | |
| if [[ ! -d /home/"$USER_NAME" ]]; then | |
| echo "no home dir" | |
| echo "exiting." | |
| fi | |
| echo "add software" | |
| export DEBIAN_FRONTEND=noninteractive | |
| apt update -y | |
| apt upgrade -y | |
| apt install xfce4 xfce4-goodies firefox chromium-browser -y | |
| apt install xrdp ufw -y | |
| snap install midori -y | |
| echo "add xrdp to ssl-cert group" | |
| adduser xrdp ssl-cert | |
| echo start xrdp | |
| systemctl start xrdp | |
| systemctl status xrdp | |
| echo "xrdp config" | |
| grep -vE '^#|^;|^$' /etc/xrdp/xrdp.ini | |
| echo "configure firewall" | |
| ufw allow 3389 | |
| #ufw allow from $(curl ifconfig.me)/32 to any port 3389 | |
| ufw allow ssh | |
| systemctl status ufw | |
| echo "install xsession" | |
| echo "xfce4-session" > /home/root/.xsession | |
| echo "xfce4-session" > /home/"$USER_NAME"/.xsession | |
| echo "export GNOME_SHELL_SESSION_MODE=ubuntu | |
| export XDG_CURRENT_DESKTOP=ubuntu:GNOME" | tee /root/.xsessionrc /home/"$USER_NAME"/.xsessionrc | |
| ls -l /root/.xsession | |
| cat /root/.xsession | |
| ls -l /home/"$USER_NAME"/.xsession | |
| cat /home/"$USER_NAME"/.xsession | |
| usermod "$USER_NAME" -aG nopasswdlogin | |
| echo "restarting xrdp" | |
| systemctl restart xrdp | |
| systemctl status xrdp | |
| echo "fw status" | |
| ufw status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment