Skip to content

Instantly share code, notes, and snippets.

@PackeTsar
Created October 12, 2021 16:30
Show Gist options
  • Save PackeTsar/b9a857f694f82898f260b6a9f7ef5f63 to your computer and use it in GitHub Desktop.
Save PackeTsar/b9a857f694f82898f260b6a9f7ef5f63 to your computer and use it in GitHub Desktop.
Use a different user on each login
# /root/newuser.sh
#
# Create and use a new user every time you log in.
#
# Setup:
# ~$ nano newuser.sh
# *paste contents of this file and save*
# ~$ chmod +x newuser.sh
# ~$ echo "bash newuser.sh" >> ~/.profile
# Create a new random username
newuser=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 5 | head -n 1)
# Add the new user
sudo adduser --quiet --disabled-password --shell /bin/bash --gecos "User" $newuser
# Set the user password
echo "$newuser:supersupersecret" | chpasswd
# Move to the users home dir
cd /home/$newuser
# Switch to the new user
su $newuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment