Skip to content

Instantly share code, notes, and snippets.

@chris-gillatt
Created November 20, 2024 05:46
Show Gist options
  • Select an option

  • Save chris-gillatt/33b0fcf55754d531a0944f9dfea3f77a to your computer and use it in GitHub Desktop.

Select an option

Save chris-gillatt/33b0fcf55754d531a0944f9dfea3f77a to your computer and use it in GitHub Desktop.
currently untested
#!/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