chrodev/create_ubuntu_user.sh

22 lines
472 B
Bash
Executable File

#!/bin/bash
USERNAME=$1
PASSWORD=$2
# Create user
useradd -m -s /bin/bash $USERNAME
# Set password
echo "$USERNAME:$PASSWORD" | chpasswd
# Add user to sudo group
usermod -aG sudo $USERNAME
# Set up VNC for the user
su - $USERNAME -c "mkdir -p ~/.vnc && x11vnc -storepasswd $PASSWORD ~/.vnc/passwd"
# Set up X11 forwarding for the user
echo "export DISPLAY=host.docker.internal:0" >> /home/$USERNAME/.bashrc
echo "User $USERNAME created with the provided password."